Data.table & devtools: install_github error - the function works locally, but not after installing the package from github

I am having problems with the data.table package after installing the package from github using devtools . My custom function (which uses the data.table functions) works when I load the function locally, however, when I create my own package on github and install the package from github, the function no longer works.

Download the required packages:

 require(PerformanceAnalytics) if(!require(PerformanceAnalytics)) install.packages("PerformanceAnalytics"); require(PerformanceAnalytics) require(data.table) if(!require(data.table)) install.packages("data.table"); require(data.table) require(devtools) if(!require(devtools)) install.packages("devtools"); require(devtools) 

Create a dummy dataset:

 data(edhec) EDHEC<-data.frame(date=index(edhec),coredata(edhec)) EDHEC<-melt(EDHEC,id.vars="date") EDHEC<-data.table(EDHEC,key=c("variable","date")) 

Install my package from github using devtools:

 install_github("r_jfreels","jfreels"); require(jfreels) 

Run my function:

 test_date(EDHEC) 

This gives an error: "Error in min (date): invalid" type "(close) of argument"

Now create the function locally:

 test_date<-function(DF) { DT<-data.table(date=DF$date,variable=DF$variable,value=DF$value,key=c('variable','value')) DT[,list(start_date=min(date),end_date=max(date)),by=variable] } 

Recheck the function:

 test_date(EDHEC) 

It works.

It drives me crazy, and I don't know what the problem is.

+4
source share
1 answer

If you add Depends: data.table to your DESCRIPTION file, it will work. However, you really should try to pass the R CMD test - right now, it is nowhere near passing.

+5
source

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


All Articles