Hi, I thought that 'coefficients' is a named list, but I can not refer to its element by something like r$coefficients$y. I used str() to check r. It says the following. Can somebody let me know what it means? ..- attr(*, "names")= chr [1:2] "(Intercept)" "y"
$ Rscript lm.R > x=1:10 > y=1:10 > r=lm(x~y) > class(r) [1] "lm" > mode(r) [1] "list" > r Call: lm(formula = x ~ y) Coefficients: (Intercept) y 1.123e-15 1.000e+00 > r$coefficients[1] (Intercept) 1.123467e-15 > r$coefficients[[1]] [1] 1.123467e-15 > r$coefficients[2] y 1 > r$coefficients[[2]] [1] 1 > > str(r) List of 12 $ coefficients : Named num [1:2] 1.12e-15 1.00 ..- attr(*, "names")= chr [1:2] "(Intercept)" "y" Regards, Peng ______________________________________________ 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.