Dear Group, Why does write.csv modify the date format when it write to a file. I have the following variable Param_Dat: dput(Param_Dat) structure(list(Last_Successful_Run = structure(1L, .Label = "30/10/2010", class = "factor")), .Names = "Last_Successful_Run", class = "data.frame", row.names = c(NA, -1L)) When I do: write.csv(Param_Dat,"Param.csv",quote=F,row.names=F) The format of the info in the file is: Last_Successful_Run 31OCT2010 I want to retain the dd/mm/YYYY format ... Please advise. ---------------------------------------------------------------------------- -------------------------- Thanks R-Helpers. Yes, this is a silly question and it will not be repeated! :-)
works fine on 2.11.1 Windows:> x <- structure(list(Last_Successful_Run = structure(1L, .Label = "30/10/2010",+ class = "factor")), .Names = "Last_Successful_Run", class = "data.frame", + row.names = c(NA, + -1L))> xLast_Successful_Run 1 30/10/2010> str(x)'data.frame': 1 obs. of 1 variable: $ Last_Successful_Run: Factor w/ 1 level "30/10/2010": 1> write.csv(x, file='x.csv') > z <- read.csv('x.csv') > zX Last_Successful_Run 1 1 30/10/2010>Your data is a 'factor' so it should not be doing any date conversion. On Mon, Nov 1, 2010 at 9:14 AM, Santosh Srinivas <santosh.srinivas at gmail.com> wrote:> Dear Group, > > Why does write.csv modify the date format when it write to a file. > > I have the following variable Param_Dat: > > dput(Param_Dat) > structure(list(Last_Successful_Run = structure(1L, .Label = "30/10/2010", > class = "factor")), .Names = "Last_Successful_Run", class = "data.frame", > row.names = c(NA, > -1L)) > > > When I do: > write.csv(Param_Dat,"Param.csv",quote=F,row.names=F) > > The format of the info in the file is: > Last_Successful_Run > 31OCT2010 > > I want to retain the dd/mm/YYYY format ... > > Please advise. > > ---------------------------------------------------------------------------- > -------------------------- > Thanks R-Helpers. Yes, this is a silly question and it will not be repeated! > :-) > > ______________________________________________ > R-help at 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
On Nov 1, 2010, at 9:14 AM, Santosh Srinivas wrote:> Dear Group, > > Why does write.csv modify the date format when it write to a file. > > I have the following variable Param_Dat: > > dput(Param_Dat) > structure(list(Last_Successful_Run = structure(1L, .Label = > "30/10/2010", > class = "factor")), .Names = "Last_Successful_Run", class = > "data.frame", > row.names = c(NA, > -1L)) > > > When I do: > write.csv(Param_Dat,"Param.csv",quote=F,row.names=F) > > The format of the info in the file is: > Last_Successful_Run > 31OCT2010Unable to reproduce. When I execute that code I get this file: Last_Successful_Run 30/10/2010 I'm guessing you are viewing that file with something other than a plain text editor.> > I want to retain the dd/mm/YYYY format ... > > Please advise.-- David Winsemius, MD West Hartford, CT > sessionInfo() R version 2.11.1 Patched (2010-06-14 r52281) x86_64-apple-darwin9.8.0 locale: [1] en_US/en_US/en_US/C/en_US/en_US attached base packages: [1] splines stats graphics grDevices utils datasets methods [8] base other attached packages: [1] Hmisc_3.8-1 survival_2.35-8 dismo_0.5-6 rJava_0.8-7 [5] raster_1.5-16 sp_0.9-72 sos_1.2-9 brew_0.1-1 [9] lattice_0.18-8 loaded via a namespace (and not attached): [1] cluster_1.12.3 grid_2.11.1 tools_2.11.1