r-package

How to make R package recommend a package hosted on GitHub?

ε祈祈猫儿з 提交于 2019-12-01 17:35:45
I'm developing an R package that works as a wrapper for functions from the parallel and Rhpc packages called ctools . I know that if I want my package to require these packages I need to include them in the Imports section of the DESCRIPTION file. When installing my package, these packages will be installed from CRAN. Similarly I can put them in the Suggests section if they aren't required, but useful. These won't be installed with my package. But, I've forked the Rhpc package and added a function that I use in my ctools package. How do I get my package to Suggest/Import this package from my

How to make R package recommend a package hosted on GitHub?

情到浓时终转凉″ 提交于 2019-12-01 16:32:22
问题 I'm developing an R package that works as a wrapper for functions from the parallel and Rhpc packages called ctools. I know that if I want my package to require these packages I need to include them in the Imports section of the DESCRIPTION file. When installing my package, these packages will be installed from CRAN. Similarly I can put them in the Suggests section if they aren't required, but useful. These won't be installed with my package. But, I've forked the Rhpc package and added a

How to profile the loading of an R package

别来无恙 提交于 2019-12-01 16:04:56
I have written this R package that takes ages (> 10s, sometimes up to 20-30s!) to load. Every time the package loads, such as when building the package at the step "** testing if installed package can be loaded" , or directly calling library("my.package") , nothing happens for 20s. This makes everything painfully slow during development: building documentation, building the package, running R check... Of course I have my suspicions (looking at you, dodgy dependency), but I need to gather evidence before axing it. Is there a way to profile the loading of the package, in order to identify the

How to profile the loading of an R package

回眸只為那壹抹淺笑 提交于 2019-12-01 15:25:17
问题 I have written this R package that takes ages (> 10s, sometimes up to 20-30s!) to load. Every time the package loads, such as when building the package at the step "** testing if installed package can be loaded" , or directly calling library("my.package") , nothing happens for 20s. This makes everything painfully slow during development: building documentation, building the package, running R check... Of course I have my suspicions (looking at you, dodgy dependency), but I need to gather

r - data.table and testthat package

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 03:53:27
I am building a package which works with data.table and which should be tested using package testthat. While the code works fine when calling from the command line, I run into issues when calling from a test case. It seems that the [] function from the base package, i.e. the function for data.frames is used when running the tests. I have created a minimum example which can be found here: https://github.com/utalo/test_datatable_testthat The package contains a single function: test <- function() { dt <- data.table(MESSAGE="Test 1234567890",TYPE="ERROR") dt[,.(MESSAGE=strwrap(MESSAGE,width = 10))

How to define “hidden global variables” inside R packages?

梦想的初衷 提交于 2019-12-01 03:51:56
I have the following 2 functions in R: exs.time.start<-function(){ exs.time<<-proc.time()[3] return(invisible(NULL)) } exs.time.stop<-function(restartTimer=TRUE){ if(exists('exs.time')==FALSE){ stop("ERROR: exs.time was not found! Start timer with ex.time.start") } returnValue=proc.time()[3]-exs.time if(restartTimer==TRUE){ exs.time<<-proc.time()[3] } message(paste0("INFO: Elapsed time ",returnValue, " seconds!")) return(invisible(returnValue)) } The function exs.time.start creates a global variable ( exs.time ) with the CPU time of the moment when I called the function. The function exs.time

Using inst/extdata with vignette during package checking R 2.14.0

和自甴很熟 提交于 2019-11-30 23:39:26
I have a package which contains a csv file which I put in inst/extdata per R-exts. This file is needed for the vignette. If I Sweave the vignette directly, all works well. When I run R --vanilla CMD check however, the check process can't find the file. I know it has been moved into an .Rcheck directory during checking and this is probably part of the problem. But I don't know how to set it up so both direct Sweave and vignette building/checking works. The vignette contains a line like this: EC1 <- dot2HPD(file = "../inst/extdata/E_coli/ecoli.dot", node.inst = "../inst/extdata/E_coli/NodeInst

Adding an external library in R package using Rcpp

纵饮孤独 提交于 2019-11-30 10:11:56
I am trying to develop an R package which uses the Sundials C library for solving differential equations. In order to not have the user install the library, I am putting the source code of the library in my package. I have put all the header files from the library in /inst/include/sundials-2.6.2 and the .c files in src/sundials-2.6.2 of my package folder. From my reading of the SO posts on this topic, sourceCpp of code in multiple files (e.g., separate .h and .cpp files should work if they are structured to be a part of the package. I am trying to run a example code file from the Sundials

Requiring OpenMP availability for use in an Rcpp package

北战南征 提交于 2019-11-30 07:33:48
I have prepared a package in R by using RcppArmadillo and OpenMP libraries and following commands: RcppArmadillo.package.skeleton("mypackage") compileAttributes(verbose=TRUE) Also, in the DESCRIPTION file I added: Imports: Rcpp (>= 0.12.8), RcppArmadillo LinkingTo:Rcpp, RcppArmadillo Depends: RcppArmadillo and in the NAMESPACE file I added: import(RcppArmadillo) importFrom(Rcpp, evalCpp) Then I run the following codes in cmd : R CMD build mypackage R CMD INSTALL mypackage.tar.gz I build and install the package in my computer and I use it now. But my colleges and friends are not able to install

How to put datasets into an R package

僤鯓⒐⒋嵵緔 提交于 2019-11-30 06:49:49
I am creating my own R package and I was wondering what are the possible methods that I can use to add (time-series) datasets to my package. Here are the specifics: I have created a package subdirectory called data and I am aware that this is the location where I should save the datasets that I want to add to my package. I am also cognizant of the fact that the files containing the data may be . rda , .txt , or .csv files. Each series of data that I want to add to the package consists of a single column of numbers (eg. of the form 340 or 4.5) and each series of data differs in length. So far,