Here is my solution to produce a date value if your data set only has week
values associated with data (ie no date).
It gives the first monday of the week.
Michael Folkes
s <- seq(as.Date("2010-01-01"), as.Date("2010-12-31"), by = "day") #produce all
days of the year
series.
Folkes, Michael:
>
> I now realize I could write code to evaluate which of the first 7 days
> in the year is a Monday and then I'd know the start of week 1 in each
> year, and multiply from there.
But note that
> library(surveillance) # ISO week
> isoWeekYear(as.Date("2010-01-01"))$ISOWeek
[1] 53
On Wed, Aug 17, 2011 at 4:52 PM, Folkes, Michael
wrote:
> Hello all,
> I'm hoping to convert a decimal value for week of the year back to a date
> object.
> Eg:
> strptime(paste(2010,1:52,sep=" "),format="%Y %W")
>
> I expected (hoped?) this would give me the date for Monday of each week.
> Ins
is a Monday and then I'd know the start of week 1 in each
year, and multiply from there.
Thanks
Michael
-Original Message-
From: David Winsemius [mailto:dwinsem...@comcast.net]
Sent: August 17, 2011 2:38 PM
To: Folkes, Michael
Cc: r-help@r-project.org
Subject: Re: [R] Convert week value
Hi Michael
I am not sure of your decimal format of the week but if you can
convert it to a calendar day of the year by multiplying by 7
then you could you could use eg if 321 was the calendar day
strptime(paste(2010, 321,sep=" "),format="%Y %j")
[1] "2010-11-17"
Regards
Duncan
Duncan Mack
On Aug 17, 2011, at 4:52 PM, Folkes, Michael wrote:
Hello all,
I'm hoping to convert a decimal value for week of the year back to a
date object.
Eg:
strptime(paste(2010,1:52,sep=" "),format="%Y %W")
Yeah, agree that seems as though it should have been successful. I
cannot get any of my i
Hello all,
I'm hoping to convert a decimal value for week of the year back to a date
object.
Eg:
strptime(paste(2010,1:52,sep=" "),format="%Y %W")
I expected (hoped?) this would give me the date for Monday of each week.
Instead, it's giving me 52 values of today's date.
Where am I erring?
Than
7 matches
Mail list logo