I am building R packages using devtools. I've built a package with some functions that I'd like to include. And I'd like to load the package and its documentation at startup. My package files are located at the location:
'~/global/Rcode/Startup Package'
My .Rprofile file looks like this:
.First <- function(){
library(devtools)
location <- '~/global/Rcode/Startup Package'
document(location)
}
However when I open R, the functions from the package are loaded but the documentation is not.
If I run the same lines of code after startup myself, namely:
library(devtools)
location <- '~/global/Rcode/Startup Package'
document(location)
then everything works and the package correctly documents. This thus seems like a rather weird bug!
(As a partial fix I can run
install(location)
and treat it like a normal r package and everything works fine, however this takes time and as I intend to update the package a lot and do not really want to have to run this every time, especially as the devtools option should work.)
Make sure
utils
is loaded before loadingdevtools
otherwise there's nohelp
function fordevtools
to overwrite.With .Rprofile:
then R startup goes:
And
help
isdevtools
version:Remove that
library(utils)
and you'll see the help function is the one in utils that won't find your package documentation.