read.xls - read in variable-length list of sheets, with their names

前端 未结 2 726
情歌与酒
情歌与酒 2021-01-18 07:55

Given several .xls files with varying number of sheets, I am reading them into R usingread.xls from the gdata package. I

2条回答
  •  死守一世寂寞
    2021-01-18 08:47

    See the sheetCount and sheetNames functions (on same help page) in gdata. If xls <- "a.xls", say, then reading all sheets of a spreadsheet into a list, one sheet per component, is just this:

    sapply(sheetNames(xls), read.xls, xls = xls, simplify = FALSE)
    

    Note that the components will be named using the names of the sheets. Depending on the content it might make sense to remove simplify = FALSE.

提交回复
热议问题