Let the following vectors:
x <- c(123456789123456789, 987654321987654321)
y <- as.character(x)
I'm trying to export y
into a csv file for later conversion into XLSX (don't ask, client requested), like so:
write.csv(y, file = 'y.csv', row.names = F)
If I open y.csv
in a pure word processor, I can see it has correctly inserted quotes around the elements, but when I open it in Excel the program insists in converting the column into numbers and showing the contents in scientific format. This requires the extra step of reformatting the column, which can be a real time-waster when one works with lots of files.
How can I format a character vector of 20-digit numbers in R so that Excel doesn't display them in scientific notation?
z <- data.frame(cbind(y, letter = c('a', 'b')))
. I want to tellwrite.csv
thatz$y
is not numeric, but it can leavez$letter
(and all the other variables in the real data frame) alone. How can I do that? – Publicity