[R] write.csv changes the format of the date
jim holtman
jholtman at gmail.com
Mon Nov 1 14:41:16 CET 2010
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))
> x
Last_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')
> z
X 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?
More information about the R-help
mailing list