I'm writing to disk a bunch of data frames using write.csv:
data_frames <- Filter(function(x) is(x, "data.frame"), mget(ls()))
for (i in 1:length(data_frames)) {
file_name<- paste0("data/to_save/",names(data_frames[i]),".csv")
write.csv(data_frames[i], file = file_name, row.names = FALSE, col.names = TRUE)
}
The issue is that header is messed adding filename to every colname like this (opened a file with notepad):
"April2016_file.customer_id","April2016_file.customerName","April2016_file.customerSurname".......
Same behaviour using write.table
and using export
script from package rio
Required result:
"customer_id","customerName","customerSurname"....