I am currently creating my first R package (:D) with R6 class thanks to RStudio, devtools and roxygen2. When my package contains only functions, I can build and load it without problem. But when I want to document R6 classes (with fields and methods like "Node" in this package https://cran.r-project.org/web/packages/data.tree/data.tree.pdf), RStudio don't want to build the package. I tried to find the trick on forums, but information about this issue is very scarce
My procedure:
- Open Rstudio, create a new project, I choose "R package"
- I fill out the name of the package and I am selecting the source files on which my packages will be based (one function and 3 classes).
-> At this point, the procedure is Ok as I obtain the correct structure with "man" with a description of my different classes, "R" with the different scripts of these classes.
But when I try to build and reload the package (having loaded beforehand the R6 packages) there is an error :
==> R CMD INSTALL --no-multiarch --with-keep.source esa
* installing to library ‘/home/cha/R/x86_64-pc-linux-gnu-library/3.0’
* installing *source* package ‘esa’ ...
** R
** preparing package for lazy loading
Error in eval(expr, envir, enclos) :
impossible de trouver la fonction "R6Class" (translation: impossible to find the function "R6Class")
Error : unable to load R code in package ‘esa’
ERROR: lazy loading failed for package ‘esa’
* removing ‘/home/cha/R/x86_64-pc-linux-gnu-library/3.0/esa’
* restoring previous ‘/home/cha/R/x86_64-pc-linux-gnu-library/3.0/esa’
Exited with status 1.
I don't understand how to fix this error as Rstudio is right: R6Class is not a function !
My questions:
Is my procedure correct ? How can I fix this error ?
I need to know whether Rstudio is able to take in account R6 classes in R package building ? If not, I can do it manually, but I just need to know in order to stop waisting my time trying with RStudio :)
Thank you in advance for your help !!
Cha