Dear colleagues, I have a dataset that looks as below.

I would like to make a new dataset that excludes the cases which are joint 
conjunctions of particular state names and years, so Connecticut and 2010, 
Maryland and 2010 and Vermont and 2010.

I'm trying the following subset code: 
newdata<- subset(bpa, (!State=="Connecticut" & year<"2010"))

It appears that it's only evaluating both criteria independently and not 
jointly, so this is returning all cases in 2008 and 2009, leaving out 
connecticut for those years as well.
How do I get subset to return a dataset based on the joint occurrence of values 
of two variables?

Yours,  Simon Kiss

str(bpa)
'data.frame':   150 obs. of  5 variables:
 $ State   : Factor w/ 50 levels "Alabama","Alaska",..: 1 2 3 4 5 6 7 8 9 10 ...
 $ year    : num  2008 2008 2008 2008 2008 ...
 $ ban     : num  0 0 0 0 0 0 0 0 0 0 ...
 $ partisan: Factor w/ 3 levels "democrat","mixed",..: 1 1 1 1 1 1 1 2 3 2 ...
 $ news    : num  1.67 2 0 0 2.38 ...
*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 519 761 7606

______________________________________________
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.

Reply via email to