Re: [R] Exclude rows by criteria

2014-04-17 Thread arun
Hi, If the column is "numeric" class, you don't need as.numeric(as.character(...)).  My response was based on your original post " I am analyzing two columns (both are factors):" Using the same example, indx1 <- with(dat1,year <=2007 |year >2012) Warning messages: 1: In Ops.factor(year, 2007) :

Re: [R] Exclude rows by criteria

2014-04-17 Thread arun
Hi, May be this helps: set.seed(49) dat1 <- data.frame(group=factor(sample(4,20,replace=TRUE)), year=factor(sample(2003:2014,20,replace=TRUE))) indx <- with(dat1, as.numeric(as.character(year)) <=2007 | as.numeric(as.character(year)) >2012 ) with(dat1[!indx,],chisq.test(group,year)) A.K. I