[R] truncating a data frame based on a function
Greg Snow
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
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
> -----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
>
>
> 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.
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list