Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yonicd/whereami

Reliably return location where command is called from in R.
https://github.com/yonicd/whereami

Last synced: 27 days ago
JSON representation

Reliably return location where command is called from in R.

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r setup, include = FALSE}

knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)

Sys.setenv(RSTUDIO_CONSOLE_WIDTH = 50)
```

[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/whereami)](https://cran.r-project.org/package=whereami)
[![](https://cranlogs.r-pkg.org/badges/whereami)](https://cran.r-project.org/package=whereami)
[![Coverage status](https://codecov.io/gh/yonicd/whereami/branch/master/graph/badge.svg)](https://codecov.io/github/yonicd/whereami?branch=master)
[![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2022_12_21-red.svg)](http://tinyurl.com/y5c5voy3)

# whereami`r if(knitr::opts_knit$get('rmarkdown.pandoc.to')=='gfm-ascii_identifiers') ''`

The goal of whereami is to reliably find where command is run from.

## Installation

``` r
remotes::install_github("yonicd/whereami")
```

## Example

```{r}
library(whereami)
library(ggplot2)
```

### General

```{r basic,R.options=list(width = 50)}
whereami()
```

### Plots

```{r plot}

ggplot(iris) +
aes(x=Sepal.Length,y=Sepal.Width) +
geom_point() +
labs(caption = sprintf('sourced from: %s',whereami()))

```

### Shiny

![](https://github.com/yonicd/whereami/blob/media/whereami_shiny.gif?raw=true)

## Non RStudio session

If you are running a non RStudio script ie from terminal R/Rscript then the package falls back to `thisfile()`, which has been migrated from [rprojroot::thisfile()](https://rprojroot.r-lib.org/reference/thisfile.html).

In this case the traceback functionality of `whereami()` to return the line where the function was sourced is not enabled.