Hi I need to remain only with the day of each date:
df<-data.frame(x=c("2014-07-24 00:00:00",
"2014-07-24 00:00:00", "2014-07-11", "2014-07-11" ,"2014-07-16" ,"2014-07-14"))
as.Date(df$x,format="%Y-%m-%d" )
I tried this:
df$dia<-as.Date(df$x, format="%d")
But I get a full date and different from the orginal.
I don't want to install another package to do this. How can I solve it? Thanks
df$x <- as.Date(df$x)
? Do you want the name of the day?weekdays(df$x)
Do you want a numeric result? Your question is not clear. – Tryckdf$x
have times. What timezone are they in? Are the times always"00:00:00"
? If you just want the day as a string, you can useformat(as.Date(df$x,format="%Y-%m-%d"), "%d")
. – Martguerita