Hello,
Try
station <- colnames(opencsv)[-1]
mat <- matrix(0, nrow=length(station), ncol=nrow(opencsv))
dimnames(mat) <- list(station, opencsv$Year)
for(st in station){
model <- lm(Year~opencsv[, st], data=opencsv)
mat[st, ] <- residuals(model)
}
write.csv(mat, "opencsv.csv")
Hop
Hi guys,
I am applying linear regression model using lm, generate the residual
and then need to output the result to a csv file. Here is my script:
maxtempstation1.lm = lm( Year ~ station1, data=opencsv)
maxstation1.res = resid(maxstation1.lm); maxstation1.res
write.csv(maxtempstation1.res, file="
2 matches
Mail list logo