I'm working with a data frame (dt
) that contains 3 columns: Time
, Temp
, Species
, such as
Temp Time Species
1 10 241 Species-X
2 11 241 Species-X
3 12 241 Species-X
4 13 241 Species-Y
5 14 241 Species-Y
6 15 240 Species-Z
... ... ... ...
41 50 178 Species-Z
There are five species in the third column.
I want to apply a linear model (lm
) with Temp
as my independent variable and Time
as the dependent variable.
So I want to test it just for species X, or Y. Further, I want to test for one of my species at a given Temp
interval (let's say 20 - 29 Degrees C).
I have tried:
lm(Temp ~ Time, data = td[Species = Species-Y])
for(i in unique(td$Species)){
model <- list(model)
model[i] <- lm(td$Time ~ td$Temp)
}
model <- function (dados) {
return(lm(td$Time[,dados] ~ td$Temp[,dados]))
}
model(dados = td$Species-X)