Skip to content

[OGRUG] Accessing pdf files in inst/

1 message · Tyler Smith

#
Hi Robert,

Are you familiar with vignettes? I think this is exactly the 
use-case they are designed for.

https://cran.r-project.org/doc/manuals/R-exts.html#Writing-package-vignettes

```
Vignettes are documents in PDF or HTML format obtained from 
plain-text literate source files from which R knows how to extract 
R code and create output (in PDF/HTML or intermediate LaTeX). 
Vignette engines do this work, using ?tangle? and ?weave? 
functions respectively. [...]

Package vignettes have their sources in subdirectory vignettes of 
the package sources. 
```

I notice that the page I linked to indicates that `inst/doc` is 
still the preferred location for additional documentation, though, 
has that changed?


`system.files` is a lower-level way to access files in your 
package. With the latest version of your package installed from 
CRAN, I can retrieve the path to the files via:

R 3.6.3:
system.file(package = "rgr", "rgr_Overview_1-1-15.pdf")
[1] 
"/home/tws/R/x86_64-pc-linux-gnu-library/3.6/rgr/rgr_Overview_1-1-15.pdf"

R version 4.0.0 beta (2020-04-14 r78227) -- "Arbor Day"
system.file(package = "rgr", "rgr_Overview_1-1-15.pdf")
[1] 
"/home/tws/hacking/r-devel/build40/library/rgr/rgr_Overview_1-1-15.pdf"

I'm not sure how best to open the files, I suspect that would be 
platform-dependent?

Good luck,

Tyler

Garrett, Robert (NRCan/RNCan) writes: