Look at the subset function (?subset), it may do what you want. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Faheem Mitha > Sent: Friday, September 21, 2007 9:24 AM > To: [email protected] > Subject: [R] truncating a data frame based on a function > > > Hi, > > Consider the following example. > > > a = c(1,2,3); b = c(4,5,6); c = cbind(a,b); c[(2 < c[,1]) & > (c[,1] < > > 4),] > > a b > 3 6 > > So, the idea is to select rows for which the value in the > first column is between 2 and 4. This works, however, I don't > like having to reference a explicitly in this fashion, and > just wondered if there was a preferred way to accomplish the > same thing. Ideally, I'd like to make use of a function. > > > Thanks, Faheem. > > ______________________________________________ > [email protected] 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. > ______________________________________________ [email protected] 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.

