Dear all, I have daily data in wide-format from 01/01/1986 to 31/12/2016 by ID. I would like to convert this to weekly average data. The data has been generated by an algorithm.
I know that I can use the lubridate package but that would require me to first convert the data to long-form (which is what I want). I am at a bit of loss of how to extract the date from the variable names and then converting the data to weekly average. Any help will be high appreciated. ### data structure(list(X1986.01.01.10.30.00 = c(16.8181762695312, 16.8181762695312, 18.8294372558594, 16.8181762695312, 18.8294372558594, 16.835693359375 ), X1986.01.02.10.30.00 = c(16.2272033691406, 16.2272033691406, 18.0772094726562, 16.2272033691406, 18.0772094726562, 16.2159423828125 ), X1986.01.03.10.30.00 = c(15.8944396972656, 15.8944396972656, 17.7444152832031, 15.8944396972656, 17.7444152832031, 15.91943359375 ), X1986.01.04.10.30.00 = c(16.2752380371094, 16.2752380371094, 18.125244140625, 16.2752380371094, 18.125244140625, 16.3352355957031 ), X1986.01.05.10.30.00 = c(15.3706359863281, 15.3706359863281, 17.2806396484375, 15.3706359863281, 17.2806396484375, 15.3556213378906 ), X1986.01.06.10.30.00 = c(15.3798828125, 15.3798828125, 17.3136291503906, 15.3798828125, 17.3136291503906, 15.4974060058594), ID = 1:6), .Names = c("X1986.01.01.10.30.00", "X1986.01.02.10.30.00", "X1986.01.03.10.30.00", "X1986.01.04.10.30.00", "X1986.01.05.10.30.00", "X1986.01.06.10.30.00", "ID"), row.names = c(NA, 6L), class = "data.frame") Sincerely, Milu [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.