[OGRUG] Accessing pdf files in inst/

Tyler Smith ty|er @end|ng |rom p|@nt@rum@c@
Fri May 1 16:21:39 CEST 2020


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:

> Good day,
>
> I trust all readers are well and coping with the Covid 
> difficulties.
>
> I have a package that I have developed and maintained since 
> 2002, 'rgr'.  When first built there were three pdf documents 
> that were stored in inst/docs.  In earlier versions of R these 
> could be accessed via the package index for the Help files, not 
> so anymore.
>
> I understand that inst/docs is no longer an acceptable folder 
> name, and I propose to place the files in a folder inst/pdf.  I 
> am still faced with the problem of providing access to display 
> these files.  My preferred solution would be access or 
> instructions through the Help files so the user could read the 
> files from within an R session.
>
> Any suggestions would be gratefully accepted.
>
> Thank you,
>
> Stay safe and well,
>
>           Bob
>
> Robert G. Garrett
>
> Emeritus Scientist, Geological Survey of Canada
> Natural Resources Canada / Government of Canada
> robert.garrett using canada.ca / Tel: 613-995-4517
>
> scientique émérite, commission géologique
> Ressources naturelles Canada / Gouvernement du Canada
> robert.garrett using canada.ca / Tél: 613-995-4517
>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-UG-Ottawa mailing list
> R-UG-Ottawa using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-ug-ottawa


-- 
Tyler Smith
plantarum.ca



More information about the R-UG-Ottawa mailing list