How do I give file name instead of full file path in cut in read.csv in R? -


fl <- /home/somefile.csv; x <- read.csv(pipe("cut -f3 -d',' fl")); 

it throws error, saying cut: fl: no such file or directory.

you can use paste combine filepath string shell commands

# create example data write.csv(mtcars, "somefile.csv")  # define filepath character string fl <- "somefile.csv"  # read in third column pasteing strings x <- read.csv(pipe(paste("cut -f3 -d',' ", fl)))  head(x) #  cyl #1   6 #2   6 #3   4 #4   6 #5   8 #6   6 

Comments