I know that this question might be similar to the previous ones, e.g., this and this. However, I found it confusing to add the row names and column names as a result of converting from list to data frame as follows:
Library("FSA", "FSAdata")
data("RuffeSLRH92")
str(RuffeSLRH92)
ruffe2 <- Subset(RuffeSLRH92,!is.na(weight) & !is.na(length))
ruffe2$logL <- log(ruffe2$length)
ruffe2$logW <- log(ruffe2$weight)
data <- Subset(ruffe2,logW >= -0.5)
LWfunction <- function(x) {
  fits <- lm(log(weight) ~ log(length), data = x)
  a <- hoCoef(fits, 2,3)
  b <- confint(fits)
  output <- list(a, b)
  return(output)
}
output <- by(data[c("weight", "length")], data[c("month", "year")], LWfunction)
df <- data.frame(matrix(unlist(output), nrow=7, byrow=TRUE),stringsAsFactors=FALSE)
df
The idea is to extract coefficient hoCoef and confint from log-transform linear regression of length-weight relationship of fish. And aggregate the result into a readable data frame. From the code above I mange to extract the "raw" result:
X1 X2       X3         X4          X5  X6           X7        X8       X9       X10
1  2  3 3.000857 0.03958601  0.02164589  58 9.828047e-01 -11.60960 2.921617 -10.86960
2  2  3 2.880604 0.03154619 -3.78478744  64 3.415156e-04 -10.94504 2.817584 -10.35515
3  2  3 2.859603 0.03171993 -4.42615042 152 1.821503e-05 -10.92607 2.796934 -10.33690
4  2  3 2.865718 0.01889957 -7.10501173 147 4.811825e-11 -10.74430 2.828368 -10.39930
5  2  3 2.893662 0.03124268 -3.40362699  67 1.126571e-03 -11.01110 2.831301 -10.45753
6  2  3 3.022135 0.03257380  0.67954496 114 4.981701e-01 -11.67896 2.957607 -11.08538
7  2  3 2.996446 0.03140263 -0.11316551  64 9.102536e-01 -11.51532 2.933712 -10.94305
X11
1 3.080097
2 2.943625
3 2.922272
4 2.903068
5 2.956022
6 3.086664
7 3.059180
So how can I get the desired output like this:
year month term Ho Value Estimate Std. Error  T  df p-value 2.5% 97.5% 
 
    