많은 시트가있는 Excel 파일이 있고 각 시트를 Excel의 시트 이름과 동일한 규칙으로 명명 된 별도의 데이터 프레임으로 가져 오는 코드가 필요합니다. .여러 개의 데이터 시트를 여러 개의 데이터 프레임으로 가져 오기 R
예에서 탭 A, B, C는 데이터 프레임 A, B 및 C로 각각 가져옵니다. length(excel_sheets(filename))
이
그런 다음 각 탭에 포함됩니다 목록 생성 파일에 시트의 수를 얻을 : 다른 스레드에서
는, 내가 좋아하는 코드를 보았다
read_excel_allsheets <- function(filename) {
sheets <- readxl::excel_sheets(filename)
x <- lapply(sheets, function(X) readxl::read_excel(filename, sheet = X))
names(x) <- sheets
x
}
을하지만 나도 몰라 거기에서 탭이 R로 가져 오는 방법.
도움을 크게 주시면 감사하겠습니다. 미리 감사드립니다.
# write test data
tf <- writexl::write_xlsx(
list("the mtcars" = mtcars, "iris data" = iris),
tempfile(fileext = ".xlsx")
)
# read excel sheets
sheets <- readxl::excel_sheets(tf)
lst <- lapply(sheets, function(sheet)
readxl::read_excel(tf, sheet = sheet)
)
names(lst) <- sheets
# shove them into global environment
list2env(lst, envir = .GlobalEnv)