Essentially what I want to do is automate this for all my data:
plants_A<-plants_sorted[plants_sorted[, 'treatment']== 'A', ]
plants_A1<-plants_A[plants_A[, 'replicate']== '1', ]
lm(weight~time, data = plants_A1)
From 'plants' I want to make lm's for all treatment and replicate combinations.
I have also managed to split the data using:
plants_treat_repl <- split(plants, paste(plants$treatment, plants$replicate))
But I can't seem to make lm's from this split data.
# sample data
structure(list(treatment = structure(c(1L, 1L, 1L, 1L, 1L, 2L ), .Label = c("A",
"B", "C", "D"), class = "factor"), replicate = c(1, 2, 3, 4, 5, 1), time =
structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("6", "8", "10", "12", "14",
"16"), class = "factor"), weight = c(2, 0, 0, 0, 0.5, 2.6), trtrep =
structure(c(1L, 5L, 9L, 13L, 17L, 2L), .Label = c("A.1", "B.1", "C.1", "D.1",
"A.2", "B.2", "C.2", "D.2", "A.3", "B.3", "C.3", "D.3", "A.4", "B.4", "C.4",
"D.4", "A.5", "B.5", "C.5", "D.5"), class = "factor")), row.names = c(NA, 6L),
class = "data.frame")