'RStudio: After "Install and Restart", the functions of an R package are not found
I have started a new project in RStudio and by connecting to a GitHub repository. Then I turned the RStudio project into an R package with usethis::create_package().
Everything seems ok. However, after I "Install and Restart" the project and attach the package (library( mypackage )), the functions in the package can not be found (RStudio does not complete typing, and an explicit call raises an error). Instead, I have to first call devtools::load_all().
The "Install and Restart" command in RStudio produces the following:
==> Rcmd.exe INSTALL --no-multiarch --with-keep.source mypackage
* installing to library 'path-to-r'
* installing *source* package 'mypackage' ...
** using staged installation
** R
** inst
** byte-compile and prepare 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 from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (mypackage)
After the restart, RStudio calls library( mypackage )
Could it be that calling create_package() for an existing project, does not create all the necessary settings (what might they be?)? When start by creating an R package in RStudio (and create a repository from the existing project), all functions can be found after build (as they should).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
