Re: [R] changing date format in a dataframe

2011-11-16 Thread Milan Bouchet-Valat
Le mercredi 16 novembre 2011 à 06:12 -0800, arunkumar a écrit : > Hi > > I have a data frame and i need to change the date format in it. > my dataframe > > X Date > 1 1/1/2009 > 2 2/1/2009 > 3 3/1/2009 > > I need to change it to 2009-01-01 See ?as.Date. In your case, I think you should use

Re: [R] changing date format in a dataframe

2011-11-16 Thread Mohamed Lajnef
Hi, If the dates are the same format and the same length you can try this : dates<-c("1/1/2009","2/1/2009","3/1/2009") dates_new<-as.Date(paste(substr(dates,1,3),substr(dates,7,8),sep="/"),format="%d/%m/%y"), you can change the format to "%m/%d/%y" Regards M Le 16/11/11 15:12, arunkumar

Re: [R] changing date format in a dataframe

2011-11-16 Thread R. Michael Weylandt
Can you dput() your data frame? There are a different few time objects in R and details might depend which one you have. Though, if it's printing like that, I'd guess it's actually a string that you can convert to a Date using as.Date(, format = XXX) where you can work out the formatting from the d