I have a dataframe as follows:
df
Date Hour ID Par1 Par2 Par3
08-01-15 0 A 2 3 4
08-01-15 0 B 4 5 6
08-01-15 1 N 2 9 10
08-01-15 1 A 3 7 23
08-01-15 1 B 4 7 22
08-02-15 0 E 2 4 12
08-02-15 0 A 3 7 9
So I want to split this dataframe by Hour as follows:
splitdata<-split(df<-split(df, df$Hour)
After splitting it, I want to apply a linear model to the split dataset.
result <- lapply(splitdata, function(df){
lm1 <-lm(Par1~Par2,data=df)
summary <- (lm1$summary)
data.frame(as.list(summary))
})
result
My results do not show anything. Though if I changed summary to:
summary <- (lm1$coef)
data.frame(as.list(summary))
Then it will produce a result.
So the main question is, how do I get a list of the summaries of each of the linear models by Hour and not just the coefficients?
Thanks!