[R] Filtering out rows

David Winsemius dwinsemius at comcast.net
Wed Nov 2 20:53:32 CET 2016


> On Nov 2, 2016, at 9:48 AM, Bryan Mac <bryanmac.24 at gmail.com> wrote:
> 
> Hi,
> 
> I am looking to filter out rows in my data set, run my analysis and
> then removing the filter. Here is my regression. I would like to
> filter out a row. For example, I would like to filter out a row,
> "Case"=1511.
> 
> npi=lm(npi_mvmt~cnavgpi,data=df)
> summary(npi)
> resid.vs.fitt.LS%<a-%{plot(npi,1)}
> resid.vs.fitt.LS
> 
> npi_lms=lmsreg(npi_mvmt~cnavgpi,data=df)
> fitted.npi_lms<-fitted(npi_lms)
> resid.npi_lms<-residuals(npi_lms)
> resid.vs.fitt.LMS %<a-%{plot(fitted.npi_lms,resid.npi_lms);
> title("npi_mvmt~cnavgpi")}
> resid.vs.fitt.LMS
> 
> plot_cnavgpi_npi_mvmt %<a-%{plot(cnavgpi,npi_mvmt);
> abline(lm(npi_mvmt~cnavgpi,data=df),lwd=2,col=2,lty=1);
> abline(lmsreg(npi_mvmt~cnavgpi,data=df),lwd=2, col=3,lty=1);
> legend('topright',c('OLS','LMS'),lty=c(1,1),lwd=c(2.5,2.5), col=c(2,3));
> title (npi_mvmt~cnavgpi) }
> plot_cnavgpi_npi_mvmt

When posting questions about code that come from non-base packages you should include library calls to all packages needed to run the code. You should also separate terms and operators with spaces.

> 
> Best,
> Bryan Mac
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list