[R] truncating a data frame based on a function
Greg.Snow at intermountainmail.org
Fri Sep 21 18:17:20 CEST 2007
Look at the subset function (?subset), it may do what you want.
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
greg.snow at intermountainmail.org
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Faheem Mitha
> Sent: Friday, September 21, 2007 9:24 AM
> To: r-help at r-project.org
> Subject: [R] truncating a data frame based on a function
> 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.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help