[R] Filter data

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Thu Dec 2 21:51:46 CET 2010


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Diogenas
> Sent: Thursday, December 02, 2010 12:09 PM
> To: r-help at r-project.org
> Subject: [R] Filter data
> 
> 
> Hello,
> I understand that question is probably stupid, but ...
> 
> I have data (polity IV index)
> "country","year","democ","autoc","polity","polity2"
> "1","Afghanistan             ",1800,1,7,-6,-6
> "2","Afghanistan             ",1801,1,7,-6,-6
> "3","Afghanistan             ",1802,1,7,-6,-6
> 
> I need to create new data sets which includes only cases after year
> 1995.
> I've tried this command:
> poli2<-poli[poli$year > 1994,] ,
>  however it generated this:
> Error in poli[poli$year > 1994, ] : incorrect number of dimensions.
> Any ideas how i can overcome this?
> 

We need more information.  You haven't given us a self-contained, reproducible example.  The syntax you show works for me.  What does 

>str(poli)
 
show?

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204




More information about the R-help mailing list