arcee123 arcee123 - 9 months ago 87
R Question

how to read two columns in XLSX into R

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, = TRUE, header=TRUE)
Dutch_Status <- read.xlsx2("File.xlsx", sheetIndex = 1, startRow = 1, colIndex=8,endRow = 10000, = 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...



Use colIndex = c(5,8).

Also, 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.