How do I convert my date and time stamp in R to date only stamp? -
this question has answer here:
i new r. have large data set 1 of columns containing time stamp. format of column content e.g. sat mar 07 18:38:01 est 2015. want create additional column in data frame date. care in second column e.g. mar 07 2015. tried other similar questions addressing different format. in advance !
this works example. let me know if works full data set:
x = "sat mar 07 18:38:01 est 2015" as.date(x, format="%a %b %d %h:%m:%s est %y") [1] "2015-03-07"
see ?strptime
more information on formatting codes parsing dates , times.
update: per comment, add data set: if data frame called df
, original column timestamp
then...
df$date = as.date(df$timestamp, format="%a %b %d %h:%m:%s est %y")
Comments
Post a Comment