1
I have the following data:
mes <- c("jan","fev","mar","abr","maio","jun","ago","set","out")
a <- c(32.3,32.7,32.6,33.1,33.0,33.5,33.4,33.4,34.9)
b <- c(19.2,19.2,19.6,19.7,19.7,19.9,20.0,20.0,20.4)
c <- c(14.7,15.0,15.6,16.2,16.4,17.0,17.7,18.3,19.1)
d <- c(24.2,24.3,24.7,25.0,25.5,26.4,26.7,27.1,27.6)
temp <- data.frame(mes,a,b,c,d)
y <- c(1, 3, 5, 7)
would like to apply a regression lm(log(mes) ~ y)
but on the lines, and using a function lapply()
, or Type Alo, to apply on all lines.
one way I found to exemplify was this:
lm(log(temp[1,])~y)
lm(log(temp[2,])~y)
lm(log(temp[3,])~y)
lm(log(temp[4,])~y)
I don’t know if it’s possible.
the database I have is extensive, if it is possible to do this, as I would to run the data, row by row, saving the regression coefficients and the adjusted R2 of the model?
I thought I’d make a list, but I’m not sure how to do it, so if you could give me at least one north, I’d be grateful.
lm(log(mes) ~ y)
It’ll be a mistake, I didn’t even try.– Rui Barradas