readxl
openxlsx
sapply(c("pipeR", "openxlsx", "readxl"), require, character.only = TRUE)
Loading required package: pipeR
Loading required package: openxlsx
Loading required package: readxl
pipeR openxlsx readxl
TRUE TRUE TRUE
Data
data("iris")
d <- iris
head(d)
openxlsx::write.xlsx(d, "iris.xlsx")
dd <- readxl::read_excel("iris.xlsx", sheet = 1)
str(dd)
Classes 窶<98>tbl_df窶<99>, 窶<98>tbl窶<99> and 'data.frame': 150 obs. of 5 variables:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
$ Species : chr "setosa" "setosa" "setosa" "setosa" ...
Another data
data("airquality")
d2 <- airquality
head(d2)
wb <- openxlsx::createWorkbook()
openxlsx::addWorksheet(wb, "iris")
openxlsx::addWorksheet(wb, "airquality")
openxlsx::writeData(wb, sheet = "iris", d)
openxlsx::writeData(wb, sheet = "airquality", d2)
openxlsx::saveWorkbook(wb, "iris-and-airquality.xlsx")
sheetnames <- readxl::excel_sheets("iris-and-airquality.xlsx")
sheetnames
[1] "iris" "airquality"
sheetnames %>>% sapply(function(x){
sh <- readxl::read_excel("iris-and-airquality.xlsx", sheet = x)
sh
}) -> dd.list
str(dd.list)
List of 2
$ iris :Classes 窶<98>tbl_df窶<99>, 窶<98>tbl窶<99> and 'data.frame': 150 obs. of 5 variables:
..$ Sepal.Length: num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
..$ Sepal.Width : num [1:150] 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
..$ Petal.Length: num [1:150] 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
..$ Petal.Width : num [1:150] 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
..$ Species : chr [1:150] "setosa" "setosa" "setosa" "setosa" ...
$ airquality:Classes 窶<98>tbl_df窶<99>, 窶<98>tbl窶<99> and 'data.frame': 153 obs. of 6 variables:
..$ Ozone : num [1:153] 41 36 12 18 NA 28 23 19 8 NA ...
..$ Solar.R: num [1:153] 190 118 149 313 NA NA 299 99 19 194 ...
..$ Wind : num [1:153] 7.4 8 12.6 11.5 14.3 14.9 8.6 13.8 20.1 8.6 ...
..$ Temp : num [1:153] 67 72 74 62 56 66 65 59 61 69 ...
..$ Month : num [1:153] 5 5 5 5 5 5 5 5 5 5 ...
..$ Day : num [1:153] 1 2 3 4 5 6 7 8 9 10 ...
devtools::session_info()
Session info ---------------------------------------------------------------------------------
setting value
version R version 3.3.1 (2016-06-21)
system x86_64, mingw32
ui RStudio (1.0.35)
language en
collate Japanese_Japan.932
tz Asia/Tokyo
date 2016-10-25
Packages -------------------------------------------------------------------------------------
package * version date source
assertthat 0.1 2013-12-06 CRAN (R 3.2.1)
base64enc 0.1-3 2015-07-28 CRAN (R 3.2.2)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.1)
digest 0.6.10 2016-08-02 CRAN (R 3.3.1)
evaluate 0.9 2016-04-29 CRAN (R 3.3.1)
htmltools 0.3.5 2016-03-21 CRAN (R 3.2.5)
jsonlite 1.1 2016-09-14 CRAN (R 3.2.5)
knitr 1.14 2016-08-13 CRAN (R 3.2.5)
magrittr 1.5 2014-11-22 CRAN (R 3.2.1)
memoise 1.0.0 2016-01-29 CRAN (R 3.2.3)
openxlsx * 3.0.0 2015-07-03 CRAN (R 3.2.2)
pipeR * 0.6.1.3 2016-04-04 CRAN (R 3.3.1)
Rcpp 0.12.7 2016-09-05 CRAN (R 3.2.5)
readxl * 0.1.1 2016-03-28 CRAN (R 3.2.5)
rmarkdown 1.0.9016 2016-10-09 Github (rstudio/rmarkdown@2158b9d)
rstudioapi 0.6 2016-06-27 CRAN (R 3.2.5)
stringi 1.1.1 2016-05-27 CRAN (R 3.2.5)
stringr 1.1.0 2016-08-19 CRAN (R 3.2.5)
tibble 1.2 2016-08-26 CRAN (R 3.2.5)
withr 1.0.2 2016-06-20 CRAN (R 3.2.5)
yaml 2.1.13 2014-06-12 CRAN (R 3.2.1)