I have a data frame that looks like this:
> head(hpr)
Week Hpr
1 199536 143111.0
2 199537 140721.9
3 199538 140864.9
4 199539 143293.1
5 199540 148913.3
6 199541 149267.6
I would like to convert this weekly data frame to a daily xts object. The answer to this question seem to solve this.
The problem here is the non standard date format, YYYYWW. I tried converting the dates with as.POSIXct but that got me nowhere:
index <- as.POSIXct(strptime(hpr[,1], "%Y%W"))
> head(index)
[1] "1995-05-28 CEST" "1995-05-28 CEST" "1995-05-28 CEST" "1995-05-28 CEST" "1995-05-28 CEST" "1995-05-28 CEST"
I wish to make an xts object that looks like this:
Date Hpr
1995-09-04 143111.0
1995-09-05 143111.0
1995-09-06 143111.0
1995-09-07 143111.0
1995-09-08 143111.0
1995-09-09 143111.0
1995-09-10 143111.0
1995-09-11 140721.9
1995-09-12 140721.9
1995-09-13 140721.9
1995-09-14 140721.9
1995-09-15 140721.9
1995-09-16 140721.9
1995-09-17 140721.9
Suggestions?
strptime
– Joshua Ulrich