Reputation: 211
I am trying to read an XLSX sheet into an R dataframe:
Dutch_List <- read.xlsx2("file.xlsx", sheetIndex = 1, startRow = 1, colIndex=5,endRow = 10000, as.data.frame = TRUE, header=TRUE)
Dutch_Status <- read.xlsx2("File.xlsx", sheetIndex = 1, startRow = 1, colIndex=8,endRow = 10000, as.data.frame = TRUE, header=TRUE)
Is there a way to read columns 5 and 8, without reading columns 5 through 8? I just want the two columns...
Thanks
Upvotes: 0
Views: 1365
Reputation: 93791
Use colIndex = c(5,8)
.
Also, as.data.frame
is TRUE
by default, so you don't need to include that argument if you want to save some typing. Likewise, if you want to read all rows, there's no need to include startRow
and endRow
.
Upvotes: 1