Rafael Laboissiere wrote:
Is there a way to prevent write.csv to transform the column names a la
make.names?  I mean, if I write the code:

    x <- structure (NULL)
    x [["a+b"]] <- c (1,2)
    write.csv (x, file = "foo.csv", row.names = FALSE, quote = FALSE)


your x is not a data.frame, hence write.csv() (or better, write.table()) converts your *list* x to a data.frame implicitly by using as.data.frame (and this tries to convert names to more regular names by make.names()). You can avoid it by either working on data.frames or stop the make.names() conversion by forcing the data.frame in advance as in:


write.csv (as.data.frame(x, optional=TRUE), file = "foo.csv", row.names = FALSE, quote = FALSE)

Uwe Ligges



I get in foo.csv:

a.b
1
2

but I want:

a+b
1
2

Any suggestions?

Cheers,


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to