I was on that post read.csv and skip last column in R but did not find my answer, and try to check directly in Answer ... but that's not the right way (thanks mjuarez for taking the time to get me back on track.
The original question was:
I have read several other posts about how to import csv files with read.csv but skipping specific columns. However, all the examples I have found had very few columns, and so it was easy to do something like:
columnHeaders <- c("column1", "column2", "column_to_skip") columnClasses <- c("numeric", "numeric", "NULL") data <- read.csv(fileCSV, header = FALSE, sep = ",", col.names = columnHeaders, colClasses = columnClasses)
All answer were good, but does not work for what I entended to do. So I asked my self and other:
And in one function, does
data <- read_csv(fileCSV)[,(ncol(data)-1)]
could work?
I've tried in one line of R
to get on data
, all 5 of first 6 columns, so not the last one. To do so, I would like to use "-" in the number of column, do you think it's possible? How can I do that?
Thanks!