Hi, there I am trying to replicate an error message in subset() to see what it is that I'm doing wrong with the datasets I am trying to work with.
Essentially, I am trying to pass a string vector to subset() in order to select a specific collection of cases (i.e., I have data for these cases in one table, and want to select data from another table that match up with the cases in the first table). The error I get is as follows: Warning messages: 1: longer object length is not a multiple of shorter object length in: is.na(e1) | is.na(e2) 2: longer object length is not a multiple of shorter object length in: `==.default`(LAKE, g) Here is an example case I've been working with (which works) that I've been trying to "break"such that I can get this error message to figure out what I am doing wrong in my case. y1<-rnorm(100, 2) x1<-rep(1:5, each=20) x2<-rep(1:2, each=10, times=10) ex.dat<-data.frame(cbind(y1,x1,x2)) ex.dat$x1<-factor(ex.dat$x1, labels=c("A", "B", "C", "D", "E")) ex.dat$x2<-factor(ex.dat$x2, labels=c("B", "D")) a<-c("D", "F") a new.dat<-subset(ex.dat, x1 == a) new.dat I thought maybe I was getting errors because I had cases in my selection vector ('a' in this case) that weren't in my ex.dat list, but subset handles this fine and just gives me what it can find in the larger list. Any thoughts on how I can replicate the error? As far as I can tell, the only difference between the case where I am getting errors and the example above is that the levels of x1 in my case are words (i.e., "Smelly", "Howdy"), but strings are strings, aren't they? Mike Michael Rennie Ph.D. Candidate, University of Toronto at Mississauga 3359 Mississauga Rd. N. Mississauga, ON L5L 1C6 Ph: 905-828-5452 Fax: 905-828-3792 www.utm.utoronto.ca/~w3rennie ______________________________________________ R-help@stat.math.ethz.ch 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.