Note from win-builder (Building a R package) - r

I can not get around this NOTE when I send my package to win-builder.
Found the following (possibly) invalid file URI:
URI: CODE_OF_CONDUCT.md
From: README.md
https://win-builder.r-project.org/xj4Cz25frL66/00check.log
https://github.com/PMassicotte/eemR
The CODE_OF_CONDUCT.md file is in my root directory and, I think, correctly linked in the README.Rmd file as follows:
Please note that the 'eemR' project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
Any ideas?

You exclude CODE_OF_CONDUCT.md from the built package in your .Rbuildignore file. So the README.md in the built package can't find the linked file.

Related

How to add external data folder into developing R package? [duplicate]

In the documentation, R suggests that raw data files (not Rdata nor Rda) should be placed in inst/extdata/
From the first paragraph in: http://cran.r-project.org/doc/manuals/R-exts.html#Data-in-packages
The data subdirectory is for data files, either to be made available
via lazy-loading or for loading using data(). (The choice is made by
the ‘LazyData’ field in the DESCRIPTION file: the default is not to do
so.) It should not be used for other data files needed by the package,
and the convention has grown up to use directory inst/extdata for such
files.
So, I have moved all of my raw data into this folder, but when I build and reload the package and then try to access the data in a function with (for example):
read.csv(file=paste(path.package("my_package"),"/inst/extdata/my_raw_data.csv",sep=""))
# .path.package is now path.package in R 3.0+
I get the "cannot open file" error.
However, it does look like there is a folder called /extdata in the package directory with the files in it (post-build and install). What's happening to the /inst folder?
Does everything in the /inst folder get pushed into the / of the package?
More useful than using file.path would be to use system.file. Once your package is installed, you can grab your file like so:
fpath <- system.file("extdata", "my_raw_data.csv", package="my_package")
fpath will now have the absolute path on your HD to the file.
You were both very close and essentially had this. A formal reference from 'Writing R Extensions' is:
1.1.3 Package subdirectories
[...]
The contents of the inst subdirectory will be copied recursively
to the installation directory. Subdirectories of inst should not
interfere with those used by R (currently, R, data, demo,
exec, libs, man, help, html and Meta, and earlier versions
used latex, R-ex). The copying of the inst happens after src
is built so its Makefile can create files to be installed. Prior to
R 2.12.2, the files were installed on POSIX platforms with the permissions in the package sources, so care should be taken to ensure
these are not too restrictive: R CMD build will make suitable
adjustments. To exclude files from being installed, one can specify a
list of exclude patterns in file .Rinstignore in the top-level
source directory. These patterns should be Perl-like regular
expressions (see the help for regexp in R for the precise details),
one per line, to be matched(10) against the file and directory paths,
e.g. doc/.*[.]png$ will exclude all PNG files in inst/doc based on
the (lower-case) extension.

In which folder in R should the 3dplot.sty file be saved?

I am creating a question in r-exams that contains a graph made in TikZ, more specifically https://texample.net/tikz/examples/the-3dplot-package/. For its correct operation it is required that the 3dplot.sty file be in a certain R folder. In which folder should I include this file?
Error message in RStudio: "!LaTeX Error: File`3dplot.sty'not found".
If you only need it for one project, simply place the .sty file in the same folder as your .rmd file. The current working folder is the normally the first place latex searches for packages, before looking in your personal texmf folder or your tex distribution.
I would strongly recommend to install this in the texmf tree of your LaTeX installation. Then it is always found, no matter where you compile a LaTeX file.
Alternatively, you can also specify it using the header argument in include_tikz() with the full absolute file path:
include_tikz(..., header = "\\usepackage{/full/path/to/3dplot}")
Note that the .sty suffix is not to be included, even when using the full file path.

R Package unable to access contents from `inst` folder [duplicate]

In the documentation, R suggests that raw data files (not Rdata nor Rda) should be placed in inst/extdata/
From the first paragraph in: http://cran.r-project.org/doc/manuals/R-exts.html#Data-in-packages
The data subdirectory is for data files, either to be made available
via lazy-loading or for loading using data(). (The choice is made by
the ‘LazyData’ field in the DESCRIPTION file: the default is not to do
so.) It should not be used for other data files needed by the package,
and the convention has grown up to use directory inst/extdata for such
files.
So, I have moved all of my raw data into this folder, but when I build and reload the package and then try to access the data in a function with (for example):
read.csv(file=paste(path.package("my_package"),"/inst/extdata/my_raw_data.csv",sep=""))
# .path.package is now path.package in R 3.0+
I get the "cannot open file" error.
However, it does look like there is a folder called /extdata in the package directory with the files in it (post-build and install). What's happening to the /inst folder?
Does everything in the /inst folder get pushed into the / of the package?
More useful than using file.path would be to use system.file. Once your package is installed, you can grab your file like so:
fpath <- system.file("extdata", "my_raw_data.csv", package="my_package")
fpath will now have the absolute path on your HD to the file.
You were both very close and essentially had this. A formal reference from 'Writing R Extensions' is:
1.1.3 Package subdirectories
[...]
The contents of the inst subdirectory will be copied recursively
to the installation directory. Subdirectories of inst should not
interfere with those used by R (currently, R, data, demo,
exec, libs, man, help, html and Meta, and earlier versions
used latex, R-ex). The copying of the inst happens after src
is built so its Makefile can create files to be installed. Prior to
R 2.12.2, the files were installed on POSIX platforms with the permissions in the package sources, so care should be taken to ensure
these are not too restrictive: R CMD build will make suitable
adjustments. To exclude files from being installed, one can specify a
list of exclude patterns in file .Rinstignore in the top-level
source directory. These patterns should be Perl-like regular
expressions (see the help for regexp in R for the precise details),
one per line, to be matched(10) against the file and directory paths,
e.g. doc/.*[.]png$ will exclude all PNG files in inst/doc based on
the (lower-case) extension.

Where to put a Dockerfile in an R package

A contributor has added a Dockerfile to my R package. When trying to upload it to CRAN, it gets flagged:
Non-standard file/directory found at top level:
'Dockerfile'
Is there a more appropriate placement for Dockerfiles within the library's directory structure?
Many thanks
You can leave it in the top level directory. Use the .Rbuildignore file to add an exclusion to the Dockerfile (and other non-standard files).
.Rbuildignore uses regex. Here's an example .Rbuildignore file:
^.*\.Rproj$
^\.Rproj\.user$
.travis.yml
.*.tar.gz
^local

How to change package destination folder in CPack?

I have a multiple module CMake project with a root CMakeLists.txt with multipe add_subdirectory macros.
As far as I understand the default for CPack/CMake is to create package in project root folder, where root CMakeLists.txt resides. I would like to create a separate install module, with its own folder and create packages there? How to do this?
To get the created packages in the "packages" subdirectory of your build directory, use:
SET(CPACK_OUTPUT_FILE_PREFIX packages)
Use the CPack variable CPACK_PACKAGE_DIRECTORY.
Example:
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Packaging")
Do not use the non-documented variable CPACK_OUTPUT_FILE_PREFIX as suggested in one of the answers. It makes the -B argument of the cpack command unusable (tested with CMake v3.21.0).
Also note that the variables CPACK_PACKAGE_FILE_NAME and CPACK_TOPLEVEL_TAG mentioned in the accepted answer are unrelated to the package (output) directory used by CPack.
Take a look at the CPACK_TOPLEVEL_TAG and the CPACK_PACKAGE_FILE_NAME variables in the documentation.

Resources