In R, create an excel sheet with multiple pages (using openxlsx)
- User
In R, create an excel sheet with multiple pages (using openxlsx)
Assistant
To create an Excel file with multiple pages (worksheets) using the openxlsx package in R, you can follow these steps:
- Load the openxlsx package:
library(openxlsx)- Create some sample data for two worksheets (you can replace these with your own data):
data1 <- data.frame( Column1 = c("Apple", "Banana", "Orange"), Column2 = c(1, 2, 3) ) data2 <- data.frame( ColumnA = c("Pencil", "Notebook", "Ruler"), ColumnB = c(4, 5, 6) )- Create the Excel file and assign the data to the first two worksheets:
write.xlsx( c(data1, data2), "output.xlsx", sheetNames = c("Fruits", "Stationery"), rowNames = FALSE, colNames = TRUE )
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.