How to fix error “closing unused connection”

痴心易碎 提交于 2020-01-04 02:58:48

问题


To read in the first 5 columns of Test.csv I may go:

x <- matrix(scan(pipe(paste0("cut -f1,2,3,4,5 -d, ","/home/test/Test.csv")),skip=1,sep=","),ncol=5)

Then if I read it using a normal method:

y <- read.csv("/home/test/Test.csv")

I get the error message:

Warning message:
closing unused connection 3 (cut -f1,2,3,4,5 -d, /home/test/Test.csv)

Is this error message a problem, and if so how do I remedy it?


回答1:


I cannot replicate the warning on my system. However, you could try closing the connection explicitly:

con <- pipe(paste0("cut -f1,2,3,4,5 -d, ","/home/test/Test.csv"))
x <- matrix(scan(con,skip=1,sep=","),ncol=5)
close(con)


来源:https://stackoverflow.com/questions/19751555/how-to-fix-error-closing-unused-connection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!