Tal Galili
2010-Jan-18 10:38 UTC
[R] Exporting a data.frame to excel using sqlSave - adds a character ' to values
Hi all,
I am using RODB to export multiple data.frames into one excel file with
multiple sheets.
One thing I can't seem to unserdatand is way the command adds the character:
'
To the beginning of each of my (non numeric) values.
Here is an example code:
library(RODBC)
library(MASS)
data(anorexia)
save2excel <- function(x, t.name) sqlSave(xlsFile, x, tablename = t.name,
rownames = FALSE)
xlsFile <- odbcConnectExcel("C:\\output-table.xls", readOnly =
FALSE)
save2excel(anorexia, "temp")
odbcCloseAll()
So the output file has
*'*Treat
instead of:
Treat
In cell - A1
Thanks,
Tal
----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Galili@gmail.com | 972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com/ (English)
----------------------------------------------------------------------------------------------
[[alternative HTML version deleted]]
Dieter Menne
2010-Jan-18 13:49 UTC
[R] Exporting a data.frame to excel using sqlSave - adds a character ' to values
Tal Galili wrote:> > I am using RODB to export multiple data.frames into one excel file with > multiple sheets. > One thing I can't seem to unserdatand is way the command adds the > character: > ' > To the beginning of each of my (non numeric) values. >This might be a problem of you running in Hebrew locale; on my machine (German) this does not occur. However, I can manually add a ' in front both of numbers and texts to denote the column as a string; the ' only shows up in the edit field on the top row, not in the data, indicating that this is a "forced string" value. Try to read back you data. I believe your strings will be ok. Dieter -- View this message in context: http://n4.nabble.com/Exporting-a-data-frame-to-excel-using-sqlSave-adds-a-character-to-values-tp1016523p1016632.html Sent from the R help mailing list archive at Nabble.com.