Create and document a package with R6 classes

I am currently creating my first R-package (: D) with the R6 class thanks to RStudio, devtools and roxygen2. When my package contains only functions, I can create and download it without any problems. 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 a package I tried to find a trick in the forums, but the information on this issue is very scarce.

My procedure:

  • Open Rstudio, create a new project, I choose the "R-package"
  • I fill in the package name and I select the source files on which my packages will be based (one function and 3 classes).

-> At this point, the procedure is OK, because I get the correct structure with a "person" with a description of my different classes "R" with different scripts of these classes.

But when I try to create and reload the package (preloading the R6 packages), an error occurs:

==> 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, because Rstudio is right: R6Class is not a function!

My questions:

Is my procedure correct? How can I fix this error?

I need to know if Rstudio can take into account the R6 classes in the R-package? If not, I can do it manually, but I just need to know to stop putting off time on RStudio :)

Thank you in advance for your help!

Cha

+4
source share
1 answer

McFlick!!

R6Class. ,

importFrom(R6, R6Class)

NAMESPACE. !!! ( : S)

, , , , .Rd .

, http://r-pkgs.had.co.nz/, , !

+4

Source: https://habr.com/ru/post/1630087/


All Articles