predict.lm keeps row names when working from several rows in newdata, but always removes rowname from a single row. The rownames are removed by the line in predict.lm predictor <- drop(X[, piv, drop = FALSE] %*% beta[piv]) What is the reason for that decision? I usually want to retain the row names.
tmp <- data.frame(x=1:4, y=c(1,3,2,5)) tmp.lm <- lm(y ~ x, data=tmp) tmp.new <- data.frame(x=5:6, y=8:7) predict(tmp.lm, newdata=tmp.new, interval="confidence") ## rownames predict(tmp.lm, newdata=tmp.new[1,,drop=FALSE], interval="confidence")## no rownames ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.