klaus.thul@infineon.com
2003-Jan-14 18:16 UTC
[R] residuals() with missing data, alignment to original data set
Hello, I have a data frame and want to do the following. Do a regression of one variable versus another: fit <- lm(a ~ b) Then I would like to plot the residuals of this fit versus a third variable: bwplot(residuals(fit) ~ group) This fails, if a or b contain NAs, because the data in the residuals() - vector are not aligned anymore to the data in the original data frame. Is there a way to solve this issue? Regards and thanks for your help Klaus
ripley@stats.ox.ac.uk
2003-Jan-14 18:41 UTC
[R] residuals() with missing data, alignment to original data set
na.action=na.exclude does this. On Tue, 14 Jan 2003 klaus.thul at infineon.com wrote:> Hello, > > I have a data frame and want to do the following. > > Do a regression of one variable versus another: > > fit <- lm(a ~ b) > > Then I would like to plot the residuals of this fit versus a third variable: > > bwplot(residuals(fit) ~ group) > > This fails, if a or b contain NAs, because the data in the residuals() - > vector are not aligned anymore to the data in the original data frame. > > Is there a way to solve this issue? > > Regards and thanks for your help > Klaus > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595