Hello,
SMALL, reproducible examples...
Anyway, it's not that difficult. Try this
d.of.w <- as.integer(format(as.Date(test1$Date, format="%d/%m/%Y"), "%w"))
str(d.of.w)
head(d.of.w)
Note that the format '%w' gives days in 0-6, where Sunday == 0. See
?strftime.
Your Friday is therefore 5.
(Or us
On Apr 22, 2012, at 2:18 PM, Raghuraman Ramachandran wrote:
I also tried:
test$Date=as.POSIXct(test$Date,format="%m%d%y")
Well, as became apparent when you eventually offered an example, you
have dates in dd/mm/ format, so it's hardly surprising that "it
didn't work" with a format
On Apr 22, 2012, at 2:12 PM, Raghuraman Ramachandran wrote:
I tried downloading using as.is and have also provided the dput
below. The
date for example is 20/4/2012 and wday gives 2 instead of 6? Thanks
for all
your help.
str(test1)
'data.frame': 1825 obs. of 7 variables:
$ Date :
On 22-04-2012, at 20:12, Raghuraman Ramachandran wrote:
> I tried downloading using as.is and have also provided the dput below. The
> date for example is 20/4/2012 and wday gives 2 instead of 6? Thanks for all
> your help.
dt <- "20/04/2012"
> as.Date(dt)
[1] "0020-04-20"
> as.Date(dt,format="
I also tried:
> test$Date=as.POSIXct(test$Date,format="%m%d%y")
> test=cbind(test,day.of.week=format(test$Date,format="%A"))
> head(test)
Date Open High Low Close Volume Adj.Close day.of.week
1 2.33 2.34 2.31 2.31 5366000 2.31
2 2.35 2.36 2.33 2.35 5382000 2.35
I tried downloading using as.is and have also provided the dput below. The
date for example is 20/4/2012 and wday gives 2 instead of 6? Thanks for all
your help.
> str(test1)
'data.frame': 1825 obs. of 7 variables:
$ Date : chr "20/04/2012" "19/04/2012" "18/04/2012" "17/04/2012" ...
$ Op
On Sun, 22 Apr 2012, Hasan Diwan wrote:
Raghu,
On 22 April 2012 09:53, Raghuraman Ramachandran wrote:
I have a data frame (from CSV file) which has its first column called Date.
The Date is in the format mm/dd/. I was trying to get the weekday for
these dates and I tried using wday() and
Raghu,
On 22 April 2012 09:53, Raghuraman Ramachandran wrote:
> I have a data frame (from CSV file) which has its first column called Date.
> The Date is in the format mm/dd/. I was trying to get the weekday for
> these dates and I tried using wday() and day.of.week() functions and both
> of
Yes dput() for a reproducible example with some minimal
reproducible code (and the packages "day.of.week" and wday() come
from...)
x <- xts(10, Sys.Date())
wday(x)
seems fine for me.
"precisely the wrong answers" -- interesting turn of phrase.
Michael
On Sun, Apr 22, 2012 at 12:53 PM, Rag
Dear R-Gurus
I have a data frame (from CSV file) which has its first column called Date.
The Date is in the format mm/dd/. 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 issu
10 matches
Mail list logo