r - What roxygen should I put when I use a function of another package in my function -
i writing many functions , trying document using roxygen2
i use futile.logger package lot, use flog.debug
function in function. @*
should use document ?
first, being aware of your
sessioninfo() getwd() # r's working directory .libpaths() # r's library location
step0 download , install necessary packages:
library(roxygen2) library(devtools) library(digest)
step1 put related ".r" files (yourfunction1.r, yourfunction2.r, yourfunction3.r) r's working directory.
step2 create package skeleton in r's working directory: sure there no folder named "yourpackage" in r's working directory before running following command. (from r's console)
package.skeleton(name = "yourpackage", code_files = c("yourfunction1.r", "yourfunction2.r", "yourfunction3.r"), path = ".")
after running package.skeleton
, folder yourpackage created in r's working directory.
delete read-and-delete-me
file windows explorer.
delete "yourpackage-package.rd" file in yourr'sworkingdirectory\yourpackage\man folder
(do not delete "yourpackage.rd" file in yourr'sworkingdirectory\yourpackage\man folder!)
step3 @ end of preamble of ".r" file (yourfunction.r), put following (if had not done in step1):
#' @importfrom futile.logger flog.debug #' @export yourfunction <- function(...) {...
step4 in description
file of package, in imports
part, add:
imports: futile.logger(>= versionnumber)
where versionnumber version number of futile.logger package using. can find version number right-click function (from yourpackage) in object browser of revolutionrenterprise; , going bottom of resultant .html file. there, version number of package shown.
in step2, package.skeleton automatically produced namespace file content is:
exportpattern("^[[:alpha:]]+")
do not handle namespace file manually.
step5 roxygenize package wanna create ("yourpackage")
library(roxygen2) roxygenize("yourpackage")
upon roxygenization, content of namespace file of yourpackage automatically converted exportpattern("^[[:alpha:]]+")
# generated roxygen2: not edit hand export(yourfunction) importfrom(futile.logger,flog.debug)
step6 build package:
(first, delete "src-i386" , "src-x64" folders (if any) in yourr'sworkingdirectoryfolder\yourpackage folder windows explorer)
(be sure again there no "yourpackage-package.rd" file in yourr'sworkingdirectory\yourpackage\man folder. if there is, delete before building)
build("yourpackage")
step7 install package:
install("yourpackage")
step8 check going loading package , running function in package.
library(yourpackage) yourfunction(6,1,2) # "yourfunction" function in package "yourpackage"
step9 check package loadable cran (comprehensive r archieve network) (if wanna share package):
(first, delete "src-i386" , "src-x64" folders (if any) in yourr'sworkingdirectoryfolder\yourpackage folder windows explorer)
(be sure again there no "yourpackage-package.rd" file in yourr'sworkingdirectory\yourpackage\man folder. if there is, delete before checking)
from dos command prompt:
start – cmd - enter. pass r's working directory (your r's working directory known via getwd()) , cran check:
cd c:\users\user\documents\revolution r cmd check yourpackage
from r's console:
devtools::check("c:/users/user/documents/revolution/yourpackage")
Comments
Post a Comment