I have created and downloaded an R package using roxygen2 development tools. When I update the source code R files, the documentation updates fine, but the function code itself does not. How do I get the function code to update when I reinstall the package with install.packages("package-name")?
I have tried inserting error messages at the beginning of every function using stop("..."). When I reinstall the code, the functions do not output an error message as they should but work as they did before I updated the code.
Each time I update the code, I use the following commands:
devtools::document()
devtools::install()
install.packages("package-name", repos=NULL, type="source")
library(package-name)
Just for further information, when I try to install the package this way:
install.packages("package-name")
I get the following error message:
Warning in install.packages :
package ‘package-name’ is not available (for R version 3.6.0)
I got this same error message when my R version was 3.6.0, and even now after updating to 3.6.1
I have not uploaded the package to any repositories, so I figured this makes sense, and instead install it locally from my package files with repos=NULL.
#' Roxygen comments - this part updates
#'
#' etc.
functionName <- function(...) {
stop("...")
...
# This function should crash with an error message every time it is called,
# but instead the function body is never updated.
}
Upon reinstalling the package, I expect the output of my functions to be an error message, but instead, they output the same result as they did before I updated the package.
Documentation updates, function bodies do not.
So it turns out I found an answer to my own question...
The problem was with a warning message I was getting:
Warning message:
In body(fun) : argument is not a function
Despite not ever using body()
, this function was getting called internally somewhere, and the warning prevented the code from being updated (but the documentation still updates, for some reason).
Clearing my global environment with rm(list=ls())
cleared my error.