2
library(openxlsx)

wb <- createWorkbook()
addWorksheet(wb, "iris")
writeData(wb, "iris", iris)

Where can I find the data/tab data for iris in wb?

EDIT:

I would like to see the data in a R session and export it back as a R object to see what it contains. Reason is, I have a function (that I cant change) that returns a workbook object with data and I would like to explore the data in R additionally before saving it.

MLEN
  • 2,162
  • 2
  • 20
  • 36

2 Answers2

3

The readWorkbook() function reads Workbook objects as data frames.

openxlsx::readWorkbook(wb)

#     Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
# 1            5.1         3.5          1.4         0.2     setosa
# 2            4.9         3.0          1.4         0.2     setosa
Mikko
  • 7,530
  • 8
  • 55
  • 92
0

I'm not sure I understand your question. but have you tried openxlsx::openXL(wb) ?

Joe Christian
  • 11
  • 1
  • 3
  • Not really what I am looking for, but thanks for mentioning that function, was not aware of it. – MLEN Jan 13 '22 at 08:42