gpt4 book ai didi

r - 数据表和开发工具 : install_github error - function works locally but not after installing package from github

转载 作者:行者123 更新时间:2023-12-04 10:17:06 27 4
gpt4 key购买 nike

我在使用 data.table 时遇到问题使用 devtools 从 github 安装软件包后的软件包.我的自定义函数(使用 data.table 功能)在本地加载函数时起作用,但是当我在 github 上创建自定义包并从 github 安装包时,该函数不再起作用。

加载所需的包:

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)

创建一个虚拟数据集:
data(edhec)
EDHEC<-data.frame(date=index(edhec),coredata(edhec))
EDHEC<-melt(EDHEC,id.vars="date")
EDHEC<-data.table(EDHEC,key=c("variable","date"))

使用 devtools 从 github 安装我的包:
install_github("r_jfreels","jfreels"); require(jfreels)

运行我的功能:
test_date(EDHEC)

这给出了一个错误:“最小(日期)错误:参数的‘类型’(闭包)无效”

现在在本地创建函数:
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]
}

再次测试函数:
test_date(EDHEC)

这有效。

这让我发疯,我不知道问题是什么。

最佳答案

如果您添加 Depends: data.table到您的说明文件,它将“工作”。然而,你真的应该努力通过 R CMD 检查——现在,它离通过还差得很远。

关于r - 数据表和开发工具 : install_github error - function works locally but not after installing package from github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16364700/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com