0

I have 4 data frames which I am trying to export 4 data frames into same workbook

list_of_dataframes <- list(
                        "Scoring" ~ store_score,
                        "Store" ~ store_ware,
                        "Brand" ~ brand_ware,
                        "Article" ~ article_ware
                      )

openxlsx::write.xlsx(list_of_dataframes, "filename.xlsx")

Error : Error in as.data.frame.default(x[[i]], optional = TRUE) :    cannot coerce class ‘"formula"’ to a data.frame

Please help in resolving this.

  • 1
    Your `list_of_dataframes` clearly is not a list of data.frames but a list of formulas. Have you looked at `print(list_of_dataframes )`? – Roland Jan 16 '20 at 14:15

1 Answers1

0

If your goal is to make a list of data.frames then you should use = instead of ~.

list_of_dataframes <- list(
                        "Scoring" = store_score,
                        "Store" = store_ware,
                        "Brand" = brand_ware,
                        "Article" = article_ware
                      )

mfidino
  • 3,030
  • 1
  • 9
  • 13
  • And no need to quote the names … after all, you also didn’t write `"list_of_dataframes" <- …`, even though you could. – Konrad Rudolph Jan 16 '20 at 14:28