4

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?

tshepang
  • 12,111
  • 21
  • 91
  • 136
user2763361
  • 3,789
  • 11
  • 45
  • 81

1 Answers1

8

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)
Roland
  • 127,288
  • 10
  • 191
  • 288