[R] predict.lm with NAs

Wincent ronggui.huang at gmail.com
Thu Apr 15 03:20:05 CEST 2010


see ?na.exclude

you can set na.action='na.exclude' when fit the model.


On 15 April 2010 09:06, Martin Batholdy <batholdy at googlemail.com> wrote:
> Hi,
>
> I wanted to use the predict.lm() function to compare the empirical data with the predicted values.
> The problem is that I have NAs in my data.
>
> I wanted to cbind my data.frame with the empirical values with the vector I get from predict.lm.
> But they don't have the same length because predict.lm just skip NA-predictions.
>
> Is there a way to get a vector with predicted values of the same length as the empirical values (with NAs)?
>
>
> thanks!
>
> ______________________________________________
> R-help at 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.
>



-- 
Wincent Rong-gui HUANG
Doctoral Candidate
Dept of Public and Social Administration
City University of Hong Kong
http://asrr.r-forge.r-project.org/rghuang.html



More information about the R-help mailing list