Re: [R] Subsetting Data

From: Jonathan Daily <biomathjdaily_at_gmail.com>
Date: Thu, 28 Apr 2011 15:24:36 -0400

Try this:

sum(dat$Number >= 10)

On Thu, Apr 28, 2011 at 3:13 PM, Abraham Mathew <abmathewks_at_gmail.com> wrote:
> I'm using the subset() function in R.
>
> dat <- data.frame(one=c(6,7,8,9,10), Number=c(5,15,13,1,13))
>
> subset(dat, Number >= 10)
>
> However, I want to find the number of all rows who meet the Number>=10
> condition.
>
> I've done this in the past with something like colSums or rowSums or another
> similar function.
> But I don't remember how to get the number of elements which meet that
> condition.
>
> function(subset(dat, Number >= 10))   #function is what i'm asking about
>
> In the above example, I'd run get 3 because there are 3 Number values
> greater than 10.

>
>
>> sessionInfo()
> R version 2.13.0 (2011-04-13)
> Platform: i686-pc-linux-gnu (32-bit)
>
>
> Help,
> Abraham
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

-- 
===============================================
Jon Daily
Technician
===============================================
#!/usr/bin/env outside
# It's great, trust me.

______________________________________________
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.
Received on Thu 28 Apr 2011 - 19:30:08 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Apr 2011 - 19:30:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive