> d <- data.frame(x=c(1,NA,3,4,5), y=c(2,4,6,8,9), row.names=paste("No.",1:5)) > predict(lm(y~x, data=d, na.action=na.omit)) No. 1 No. 3 No. 4 No. 5 2.2 5.8 7.6 9.4 > d$y - predict(lm(y~x, data=d, na.action=na.omit)) [1] -0.2 -1.8 -1.6 -1.4 6.8 Warning message: In d$y - predict(lm(y ~ x, data = d, na.action = na.omit)) : longer object length is not a multiple of shorter object length > predict(lm(y~x, data=d, na.action=na.exclude)) No. 1 No. 2 No. 3 No. 4 No. 5 2.2 NA 5.8 7.6 9.4 > d$y - predict(lm(y~x, data=d, na.action=na.exclude)) No. 1 No. 2 No. 3 No. 4 No. 5 -0.2 NA 0.2 0.4 -0.4
Which do you prefer? Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of iliketurtles > Sent: Wednesday, January 04, 2012 2:15 PM > To: r-help@r-project.org > Subject: Re: [R] problem in R > > Michael, thank you for your post, I learned a lot. > > Why is it that people prefer na.exclude to na.omit? > > ----- > ---- > > Isaac > Research Assistant > Quantitative Finance Faculty, UTS > -- > View this message in context: > http://r.789695.n4.nabble.com/problem-in-R-tp4260254p4263119.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. ______________________________________________ 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.