[R] Exporting a data.frame to excel using sqlSave - adds a character ' to values

Juliette Fabre juliette_fabre at yahoo.fr
Thu Mar 29 10:23:26 CEST 2012


OK, finally the problem comes from the argument colnames = TRUE in the
sqlSave function.
It transforms all the columns into string in Excel ......



Ivan Calandra-2 wrote
> 
> Hi,
> 
> I cannot test with RODBC because it doesn't work on my Mac, but if RODBC 
> is not necessary to you, you could do the same using xlsx::write.xlsx(), 
> or xlsReadWrite::wirte.xls().
> 
> For example:
> library(xlsx)
> write.xlsx(your_df, file="file.xlsx")
> 
> HTH,
> Ivan
> 
> --
> Ivan CALANDRA
> Université de Bourgogne
> UMR CNRS/uB 6282 Biogéosciences
> 6 Boulevard Gabriel
> 21000 Dijon, FRANCE
> +33(0)3.80.39.63.06
> ivan.calandra@
> http://biogeosciences.u-bourgogne.fr/calandra
> 
> 
> Le 28/03/12 09:11, Juliette Fabre a écrit :
>> structure(list(Parameter_Name = c("Cd Cadmium", "Cd Cadmium",
>> "Cd Cadmium", "Cd Cadmium", "Cd Cadmium", "Cd Cadmium", "Cd Cadmium",
>> "Cd Cadmium", "Cd Cadmium", "Cd Cadmium", "Cd Cadmium", "Cd Cadmium",
>> "Cd Cadmium", "Cd Cadmium", "Cd Cadmium"), Unit = c("ppb ", "ppb ",
>> "ppb ", "ppb ", "ppb ", "ppb ", "ppb ", "ppb ", "ppb ", "ppb ",
>> "ppb ", "ppb ", "ppb ", "ppb ", "ppb "), date = structure(c(12851,
>> 12872, 12906, 12956, 12993, 13025, 13041, 13070, 13094, 13118,
>> 13126, 13161, 13180, 13193, 13223), class = "Date"), `S5 piezometre` =
>> c(6.41,
>> 7.58, NA, 34.151, 11.83, 8.17, 5.86, 130.4886, 179.5569, 180.9052,
>> 131.6477, 81.3172, NA, 97.8383, 88.5979), `S1 Source Reigous ` = c(96.74,
>> 104.97, 76.842, 122.85, 102.29, 100.63, 79.81, 110.2931, 88.6012,
>> NA, 48.4062, 80.8052, 98.7633, 93.452, 83.5394), COWG = c(86.03,
>> 87.67, 61.503, 96.359, NA, 90.44, 61.16, 100.6402, 67.2333, NA,
>> 39.5782, 62.3266, 56.2315, 60.829, 79.3607), GAL = c(64.07, 56.33,
>> 43.15, 79.538, 57.77, 61.81, 33.35, 79.0689, 20.6995, NA, 30.051,
>> 40.5197, 8.2002, 32.4497, 52.7988), Confluence = c(46.774, 40.813,
>> 86.655, 74.219, 19.19, 9.468, 80.124, 83.3786, 36.4044, NA, 77.4461,
>> 69.923, NA, 0.0665, 82.5202), `Amous plus 1200` = c(0.2025, 0.1851,
>> 0.745, 0.1023, 0.0756, 0.0816, 2.1559, 0.3747, 1.1879, NA, 1.7184,
>> 2.1946, NA, 1.7998, 1.9063)), .Names = c("Parameter_Name", "Unit",
>> "date", "S5 piezometre", "S1 Source Reigous ", "COWG", "GAL",
>> "Confluence", "Amous plus 1200"), class = "data.frame", row.names = c(NA,
>> 15L))
> 
> ______________________________________________
> R-help@ 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.
> 


--
View this message in context: http://r.789695.n4.nabble.com/Exporting-a-data-frame-to-excel-using-sqlSave-adds-a-character-to-values-tp1016523p4514811.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list