Raghu,

On 22 April 2012 09:53, Raghuraman Ramachandran <optionsra...@gmail.com>wrote:

> I have a data frame (from CSV file) which has its first column called Date.
> The Date is in the format mm/dd/yyyy. I was trying to get the weekday for
> these dates and I tried using wday() and day.of.week() functions and both
> of them gave me precisely the wrong answers. I think the issue lies in the
> proper formatting of dates. The class of this column is a factor class and
> hence I tried converting into POSIXlt, xts, zoo objects and yet I could not
> get the weekday correctly. Anyone has any suggestions please?
>

Try this:
# assume dataIn is where the CSV files data is...
dataIn$Date <- as.POSIXct(dataIn$Date, format='%m/%d/%y')
dataIn <- cbind(dataIn, day.of.week = format(dataIn$Date, format='%A')

-- 
Sent from my mobile device
Envoyait de mon portable

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to