Skip to content

changing date format in a dataframe

4 messages · arunkumar1111, Milan Bouchet-Valat, R. Michael Weylandt +1 more

#
Le mercredi 16 novembre 2011 ? 06:12 -0800, arunkumar1111 a ?crit :
See ?as.Date. In your case, I think you should use
df[[2]] <- as.Date(df[[2]], format="%d/%m/%Y")

This is assuming df is your dataframe, and that you're using the
day/month/year syntax.

To print it into another format, see ?format.Date

Regards
#
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 documentation in ?strptime.

Michael
On Wed, Nov 16, 2011 at 9:12 AM, arunkumar1111 <akpbond007 at gmail.com> wrote: