1
votes

I have a data frame with a load profile for one year. The first column is stored as POSIXct by hour from "2011-01-01 00:00:00" to "2011-12-31 23:00:00". Second columns is stored as numeric with several data.

df <- as.data.frame(matrix(ncol = 2,nrow = 8760))

df[,2] <- as.data.frame(rnorm(8760,50000,10000))

df[,1] <- as.data.frame(seq(from = as.POSIXct("2011-01-01 00:00:00"),
                           to = as.POSIXct("2011-12-31 23:00:00"),
                           by = "hours"))

I want to calculate an average day load profile. I've tried to work with the xts package and period.apply but I wasn't working. Any ideas?

Thanks

1
Forgive my ignorance. What is an average day profile?Roland
Do you just want the mean of each day?GSee
One day where the first hour is the mean of all the other first hours of the year, second hour is mean of all the other second hours and so on.max.mustermann
Create a 'grouping factor' from the hour of the day -- by formatting the time info down to just hour -- and the aggregate over all the hours using mean() as the aggregation function.Dirk Eddelbuettel
@Roland Es geht um Lastprofile im Stromnetz der Übertragungsnetzbetreiber in Deutschland.max.mustermann

1 Answers

3
votes

It seems like you want something like:

aggregate(V2~format(V1,"%H"), data=df, FUN=mean)