https://github.com/yonicd/whereami
Reliably return location where command is called from in R.
https://github.com/yonicd/whereami
Last synced: about 1 month ago
JSON representation
Reliably return location where command is called from in R.
- Host: GitHub
- URL: https://github.com/yonicd/whereami
- Owner: yonicd
- License: other
- Created: 2019-02-23T14:33:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T20:37:57.000Z (over 2 years ago)
- Last Synced: 2025-02-16T18:05:31.184Z (about 2 months ago)
- Language: HTML
- Homepage: https://yonicd.github.io/whereami/index.html
- Size: 14.8 MB
- Stars: 41
- Watchers: 6
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - yonicd/whereami - Reliably return location where command is called from in R. (HTML)
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)
```[](https://cran.r-project.org/package=whereami)
[](https://cran.r-project.org/package=whereami)
[](https://codecov.io/github/yonicd/whereami?branch=master)
[](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

## 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.