I have a dataframe call "Data" below, I want to split it by the first column and create separate CSV files with it.
For some reason when I got to the pwalk function, to do the export CSV by each file, it gives me an error.
The error says it's not a dataframe, but even when I convert it to a dataframe still throws an error.
any help would be great!
Data = data.frame(
stringsAsFactors = FALSE,
A = c(1L, 2L, 3L, 4L),
B = c("a", "b", "c", "d")
)
Files = split(Data, Data$A)
pwalk(Files, ~write_csv(Files, path = paste0(Files, ".csv"))) ```