Reliably Return the Source and Call Location of a Command

Robust and reliable functions to return informative outputs to console with the run or source location of a command. This can be from the 'RScript'/R terminal commands or 'RStudio' console, source editor, 'Rmarkdown' document and a Shiny application.


CRAN_Status_Badge Coveragestatus CovrpageSummary

whereami

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

Installation

remotes::install_github("yonicd/whereami")

Example

library(whereami)
library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.2.2

General

whereami()
#> ── Running print(x) at README.Rmd, encoding = UTF-

Plots


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().

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

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("whereami")

0.2.0 by Jonathan Sidi, 4 years ago


https://github.com/yonicd/whereami


Report a bug at https://github.com/yonicd/whereami/issues


Browse source code at https://github.com/cran/whereami


Authors: Jonathan Sidi [aut, cre] , Colin Fay [ctb] , Kirill Müller [aut]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports utils, graphics, grDevices, stats, cli, rstudioapi, jsonlite

Suggests magrittr, ggplot2, kableExtra, testthat, covr, knitr, rmarkdown


See at CRAN