klmr / box

Write reusable, composable and modular R code
https://klmr.me/box/
MIT License
862 stars 48 forks source link

Don’t fail if ‘rstudioapi’ isn’t installed #293

Closed klmr closed 2 years ago

klmr commented 2 years ago

Currently ‘box’ assumes that ‘rstudioapi’ is installed if the code is run from inside RStudio:

https://github.com/klmr/box/blob/0345109492c166b13edd0a4c151e1fa2a81dfab4/R/paths.r#L193

However, this is apparently not always the case. Make code conditional on the package’s existence, or avoid depending on it altogether.

klmr commented 2 years ago

Could probably be implemented as as.environment("tools:rstudio")$.rs.api.getActiveDocumentContext()$path. Caveat: this uses private (?) RStudio APIs.

klmr commented 2 years ago

See unresolved comment on 461c706.