Displaying 3 results from an estimated 3 matches similar to: "Convert daily data to weekly data"
2018 May 29
3
Convert daily data to weekly data
Dear Petr,
Thanks for your reply and the solution. The example dataset contains data
for the first six days of the year 1986. "X1986.01.01.10.30.00" is 01
January 1986 and the rest of the variable is redundant information. The
last date is given as "X2016.12.31.10.30.00".
I realized that I missed one information in my previous email, I would like
to compute the weekly average
2018 May 29
0
Convert daily data to weekly data
Hi
Based on your explanation I would advice to use
?cut.POSIXt
with breaks "week". However your data are rather strange, you have data frame with names which looks like dates
names(test)
[1] "X1986.01.01.10.30.00" "X1986.01.02.10.30.00" "X1986.01.03.10.30.00"
[4] "X1986.01.04.10.30.00" "X1986.01.05.10.30.00"
2018 May 29
0
Convert daily data to weekly data
Forgot the year if you also want to summarise by that.
> x <- structure(list(X1986.01.01.10.30.00 = c(16.8181762695312,
16.8181762695312,
+ 18.8294372558594, 16 ....
[TRUNCATED]
> library(tidyverse)
> library(lubridate)
> # convert to long form
> x_long <- gather(x, key = 'date', value = "value", -ID)
> #