What is the best way to update .Rd files for my new functions of my package ?
I added a function to my R script and create a .Rd file to explain this function but when I rebuilt my package with :
install("CAPepitesPRO",dependencies = T)
library(CAPepitesPRO)
The pkg compilation works fine :
installing help indices
converting help for package 'mypkg'
finding HTML links ... fini
mypkg-package html
func1 html
func2 html
func3 html
** building package indices
** testing if installed package can be loaded
*** arch - i386
*** arch - x64
* DONE (mypkg)
In R CMD INSTALL
but when I try to print the help of func3 whith ?func3 I have this error :
No documentation for ‘func3’ in specified packages and libraries:
you could try ‘??func3’
you should run the following
document("yourpath/CAPepitesPRO")
before the following
install("CAPepitesPRO",dependencies = T)
Related
I am currently building an R package, call it mypackage. I generated a package vignette using devtools::use_vignette("my-vignette"), and filled in my-vignette with content. Of course, because it is a package vignette, I need to demonstrate the use of the functions and data contained in this package itself. However, I'm having issues loading the package and its contents when knitting the vignette.
All of the code chunks in the vignette run without error on my local computer, even after restarting R and clearing the workspace. However, when I attempt to build the package using devtools::build(), the build fails with:
Error in library(mypackage): there is no package called `mypackage` Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> library Execution halted
The full output in the Console from devtools::build() is:
* checking for file ‘/path/to/mypackage/DESCRIPTION’ ... OK
* preparing ‘mypackage’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
Quitting from lines 39-44 (my-vignette.Rmd)
Error: processing vignette 'my-vignette.Rmd' failed with diagnostics:
'my_function' is not an exported object from 'namespace:mypackage'
Execution halted
devtools::document() runs without error, but devtools::build_vignettes() aparently reaches a different error where it cannot use a specific function (but seems to be able to load the package itself):
> devtools::build_vignettes()
Building mypackage vignettes
Moving basic-mypackage-vignette.html, basic-mypackage-vignette.R to inst/doc/
Copying basic-mypackage-vignette.Rmd to inst/doc/
> devtools::build()
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD build \
'/path/to/mypackage' --no-resave-data --no-manual
* checking for file ‘/path/to/mypackage/DESCRIPTION’ ... OK
* preparing ‘auctestr’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ... ERROR
Quitting from lines 39-44 (my-vignette.Rmd)
Error: processing vignette 'my-vignette.Rmd' failed with
diagnostics:
could not find function "my_function"
Execution halted
Error: Command failed (1)
> devtools::document()
Updating mypackage documentation
Loading mypackage
I assume this is because the package itself does not exist in my R library; I am just loading that package using devtools::load_all() when doing development. How can I get around this and load my package in order to use its functions and data in the package vignette? Specifically, how can I make the package in its functions available to whatever environment knitr is using to knit the vignette?
I have seen other package vignettes load the package directly using library() without issue; for example, in the stringr vignette.
I hope readers can evaluate this without a fully reproducible example; reproducing the entire example is difficult because it requires a full R package directory structure that is difficult to replicate or share here.
I do load directly my package in my vignettes (library(my_package)).
But considering your error, it might not be the problem...
Can you make sure that my_function is indeed exported. You should add the following code ate the end of the documentation of your function.
#' #export
I added a chunk
```{r, include=FALSE}
devtools::load_all(".")
```
at the beginning of the vignette to work around the problem.
However, this doesn't fix the actual problem, as this should not be necessary.
Alternatively you could use the ::: notation, especially if you are not exporting that function, e.g.
mypackage:::my_function()
I am unable to generate .Rd documentation files for my package using RStudio and Roxygen2. First, let me mention that I have gone through similar problems posted here and have already done the following:
Roxygen2 blocks initiated at the beginning of file with a #'
Configured Build Tools>Checked generate documentation with Roxygen> Configure > Checked all fields under 'Use roxygen to generate' and 'Automatically roxygenize when running'
Made sure there were no .Rd files in the 'man' folder
And even after that, when I perform a 'Build and Reload' on RStudio I get the following output (please note the line that reads: No man pages found in package MYPACKAGE:
=
=> devtools::document(roclets=c('rd', 'collate', 'namespace', 'vignette'))
>
Updating MYPACKAGE documentation
Loading MYPACKAGE
Documentation completed
==> Rcmd.exe INSTALL --no-multiarch --with-keep.source MYPACKAGE
installing to library C:/Users/user/Documents/R/win-library/3.3
installing source package 'MYPACKAGE' ...
** R
** data
* moving datasets to lazyload DB
** preparing package for lazy loading
No man pages found in package 'MYPACKAGE'
** help
* installing help indices
** building package indices
** testing if installed package can be loaded
DONE (MYPACKAGE)
Edit:
Upon further investigation, it appears that this was caused by the fact that I have sub-directories within my R directory, which is not supported by default. A possible solution was located here which, however, I haven't yet tried out. I will report back with the outcome as soon as I am able to perform the tests.
I had the same error. roxygen2 was creating correctly the md files in the /man directory but they were not found at compilation time. I had the following error.
No man pages found in package
After a bit of time I found that in one of the R file I had a source statement
source("C:/Users/vaulot/Google Drive/Scripts/R library/dv_function_pr2.R")
My guess is that there was some code in the source file interfering with roxygen2.
I am trying to build a package with compiled C code in R using 'RStudio' and 'devtools' in a Windows environment.
Only one of the function uses the C code in src folder. The source package works fine. I can use all the functions. I am able to compile the C code using devtools::document() and the corresponding .dll and .o file also appears in the src folder. Then I can load the code using dev_tools::load_all or Ctrl+Shift+L and run all the functions.
However when I am building and reloading the package using Ctrl+Shift+B, I am not able to use the particular function. The function is missing from the package even thought the documentation is retained. I also get the error telling that the corresponding .dll is not loaded.
Error in library.dynam.unload(name, system.file(package = name)) :
DLL ‘mypackage.dll’ was not loaded
I get the same results when I am using devtools::build with binary=TRUE.
However I can find the .dll file in the library Documents\R\win-library\3.0\mypackage\libs\i386\mypackage.dll. Why is this dynamic library from compiled code not being loaded?
PS: 1) devtools::has_devel() is giving TRUE
2) I am forced to use .C instead of .Call.
This is the result of the R CMD INSTALL
* installing to library 'C:/Users/lenovo/Documents/R/win-library/3.0'
* installing *source* package 'mypackage' ...
** libs
make: Nothing to be done for `all'.
installing to C:/Users/lenovo/Documents/R/win-library/3.0/mypackage/libs/i386
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (mypackage)
I was able to solve this on Windows 10 with R 3.5 by adding the following function to a file in the R/ folder.
.onUnload <- function (libpath) { library.dynam.unload("mypackage", libpath)}
Here is the reference where I found it.
My previously-functioning R package lllcrc recently broke, so I tweaked it, and now I'm having trouble building it again because it acts like it can't see my documentation files:
R CMD INSTALL lllcrc
* installing to library ‘/home/[...]/3.1’
* installing *source* package ‘lllcrc’ ...
** R
** preparing package for lazy loading
** help
No man pages found in package ‘lllcrc’
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (lllcrc)
This is totally weird because I definitely have a complete set of .Rd files in the man folder; in fact, I generated all of these using roxygen2, and all of this worked previously. The R CMD INSTALL even works enough so that the package actually installs and all of its examples run. But documentation is missing. Running ?foo just gives a "no documentation" message.
Another thing: R CMD Rd2pdf lllcrc generates the .pdf documentation as I would expect.
Any ideas?
I just had the same error message ... if you are using roxygen and RStudio then your problem might be the same. The reason became apparent when looking at "Configure build tools" in the "Build" drop-down menu: you need to tick the checkbox "Generate documentation with Roxygen". After that, everything worked.
Issue:
I'm just trying to build a few packages from source and am running into an error
Error: unexpected symbol in "tools:::.test_load_package('rbenchmark',
'\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell"
Full output below:
C:\ROracle>R CMD INSTALL --build --merge-multiarch rbenchmark_1.0.0.tar.gz
install for i386
* installing to library '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15'
* installing *source* package 'rbenchmark' ...
** package 'rbenchmark' successfully unpacked and MD5 sums checked
** R
** demo
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: unexpected symbol in "tools:::.test_load_package('rbenchmark', '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell"
Execution halted
ERROR: loading failed
* removing '\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15/rbenchmark'
Question:
Is the error coming from the apostrophe (') from O'Dell in the path?
If yes, is it a bug since it isn't escaping the apostrophe in the directory?
Is it trying to install into my default library?
If yes, can I change the library as a parameter in R CMD INSTALL?
If I can't specify the library, should I remove that library altogether?
Extra Info:
Here's the output of .libPaths()
[1] "\\\\per-homedrive1.corp.something.org/homedrive$/Tommy.O'Dell/R/win-library/2.15"
[2] "C:/Program Files/R/R-2.15.2/library"
[3] "C:/Program Files/RStudio/R/library"
As I see it, the error comes from the apostrophe - R can't know that this doesn't end the path, but is part of it. Try it without it and it should work I guess. One solution might be also to use this kind of quotation instead " ", maybe this works out as well, because then the apostrophe doesn't end it any more...
EDIT: In order to install a package foo via command line to an specific library folder via command line you can use
R CMD build foo
R CMD INSTALL -l /home/daniel/myPkg/ foo_1.0.tar.gz
This means in your case this should work:
R CMD INSTALL --build --merge-multiarch -l C:/Program Files/RStudio/R/library rbenchmark_1.0.0.tar.gz