[R] Date Time in R
Shivi Bhatia
shivipmp82 at gmail.com
Tue Jul 26 13:05:22 CEST 2016
Hi Team,
This scenario may have come across a number of times however i checked
nabble & SO and couldn't find a solution hence request assistance.
I have a date variable in my data-set eir. The class of this var was
character while i had read the file in r studio. Example of date - 05-30-16
To change this i have used eir$date<- as.Date(eir$date, "%m-%d-%y"). This
converts it to a date variable. However when i check few obs
with head(eir$date) all the results are <NA>.
I also need to create weekdays from this date variable but until i get this
resolved i cant find a weekday. For weekday i have used:
eir$week<- (eir$date)
eir$week<- weekdays(as.Date(eir$week))
class(eir$week)
eir$week<- as.factor(eir$week)
head(eir$week)
Head of this eir$week results again as expected in <NA> but shows Levels:
Friday Monday Saturday Sunday Thursday Tuesday Wednesday
Not sure what i should do here. Kindly suggest.
[[alternative HTML version deleted]]
More information about the R-help
mailing list