Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
导出插入符号将结果摘要重采样为dataframe/csv_R_R Caret - Fatal编程技术网

导出插入符号将结果摘要重采样为dataframe/csv

导出插入符号将结果摘要重采样为dataframe/csv,r,r-caret,R,R Caret,我运行了几个train对象,并通过插入符号中的resamples()函数收集了重采样结果。但是,我希望将这些结果导出到数据帧,或者理想情况下直接导出到csv。有什么简单的方法可以做到这一点吗 谢谢 使用write.csv()函数 write.csv(data,file="Your_FileName.csv",row.names=F) 我更喜欢从CSV中删除行名,但不管您喜欢什么,我知道这个问题已经有一百万年的历史了,但我遇到了完全相同的问题,如果其他人遇到这个问题,您必须先将其写入数据帧: r

我运行了几个train对象,并通过插入符号中的resamples()函数收集了重采样结果。但是,我希望将这些结果导出到数据帧,或者理想情况下直接导出到csv。有什么简单的方法可以做到这一点吗

谢谢

使用
write.csv()
函数

write.csv(data,file="Your_FileName.csv",row.names=F)

我更喜欢从CSV中删除行名,但不管您喜欢什么,我知道这个问题已经有一百万年的历史了,但我遇到了完全相同的问题,如果其他人遇到这个问题,您必须先将其写入数据帧:

resamples <-data.frame(pls_model$resample)

遗憾的是,summary.resamples不能直接转换为数据帧。使用write.csv命令,它抛出以下错误:
as.data.frame.default(x[[i]],optional=TRUE,stringsAsFactors=stringsAsFactors)中的错误:无法将类“summary.resamples”强制为数据。frame
请添加有关数据集的更多信息。可能使用
str(数据)
。如果您对某些内容运行了summary函数,则可能必须提取特定元素,例如
summary。重新采样$coef
,以获得所需的结果
perf
write.csv(resamples, file = "Your_FileName.csv")