I have named list of dataframes, i.e.:
dfs <- list("foo" = df1,
"bar" = df2,
"baz" = df3,
...)
I want to write each df in separate csv file with name as in the list, for that I have a simple loop:
for (i in c(1: length(dfs))) {
write.table(dfs[i],
names(dfs)[i],
row.names = FALSE,
sep = ",",
fileEncoding = "Windows-1252")
}
It works nice, except the output csv files get prefix in the column names, which equals to the df name in the list, i.e. the columns of first df in csv (file "foo.csv"
) become "foo.Column1"
, "foo. Column2"
, etc. I do not have those prefixes in my original dataframes and want to them not to get written in csv file. Is it possible? Thanks!