使用fread函数和输入错误

时间:2019-01-29 16:00:57

标签: r

我在编写脚本和使用fread函数时正在尝试一些问题。这是我的代码以及一些解释性注释:

 #From the file "Collar_#.txt", just select the columns ACTIVITY_X, ACTIVITY_Y, ACTIVITY_Z and Event

    dataraw<-fread("Collar_41361.txt", select = c("ACTIVITY_X","ACTIVITY_Y","ACTIVITY_Z","Event"))

    #Now, delete all rows containg the string "End"

 datanet<-dataraw[!grepl("End", dataraw$Event),]

    #Then, read only the columns ACTIVITY_X, ACTIVITY_Y and ACTIVITY_Z until row 150 from datanet

train2<-fread(datanet,header=TRUE,select=c("ACTIVITY_X","ACTIVITY_Y","ACTIVITY_Z"),nrows=150)

要查看datanet的组织方式Click here的示例

现在,在执行代码的最后一行之后,我得到以下错误消息:

Error in fread(datanet, header = TRUE, select = c("ACTIVITY_X", "ACTIVITY_Y",  : 
  input= must be a single character string containing a file name, a system command containing at least one space, a URL starting 'http[s]://', 'ftp[s]://' or 'file://', or, the input data itself containing at least one \n or \r

我得到fread输入应该是文件名,但不能不是datanet这是脚本中的对象吗?然后我该如何解决此问题,以便我可以读取基本上train2的表datanet,而没有“事件”列到第150行?

感谢任何输入!

0 个答案:

没有答案