Skip to content

Handling file paths in development vs installed directory #903

Answered by ColinFay
yogat3ch asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @yogat3ch,

This is what the app_sys() function was designed for. You can find it inside the app_config.R file.

L inst/
  L this.xyz

can be read with app_sys("this.xyz")

L inst/
  L that / 
    L this.xyz

can be read with app_sys("that/this.xyz")

This function is a wrapper around system.file(package = ), that allows to point to the current directory (during dev) or to the path where the package is installed on the current machine. That allows to refer to file on any computer.

For example, on my laptop, if I want to refer to https://github.com/ThinkR-open/golem/tree/master/inst/shinyexample

> system.file("shinyexample", package = "golem")
[1] "/Users/colin/Library/R/x86_64/4.2/library…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yogat3ch
Comment options

Answer selected by yogat3ch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #902 on August 17, 2022 05:41.