我知道可以使用包XLConnect只读取某些列。但是也可以只读取某些行吗?
demoExcelFile <- system.file("demoFiles/mtcars.xlsx", package = "XLConnect")
wb <- loadWorkbook(demoExcelFile)
# Read the columns 1, 3 and 5 from the sheet 'mtcars' (with default header = TRUE)
data <- readWorksheet(wb, sheet = "mtcars", keep=c(1,3,5))
答案 0 :(得分:1)
使用readWorksheet读取所有行,然后从data.frame中选择某些行
例如:
data <- readWorksheet(wb, sheet = "mtcars")
new.data <- data[c(10, 20, 30), ]