[R] counting the number of rows that satisfy a certain criteria
kate.ignatius at gmail.com
Sat Jun 21 17:34:59 CEST 2014
On Sat, Jun 21, 2014 at 11:05 AM, Jorge I Velez
<jorgeivanvelez at gmail.com> wrote:
> Hi Kate,
> You could try
> sum(X[, 1] == 1 & X[, 2] == 1)
> where X is your data set.
> On Sun, Jun 22, 2014 at 12:57 AM, Kate Ignatius <kate.ignatius at gmail.com>
>> I have 4 columns, and about 300K plus rows with 0s and 1s.
>> I'm trying to count how many rows satisfy a certain criteria... for
>> instance, how many rows are there that have the first column == 1 as
>> well as the second column == 1.
>> I've tried using rowSums and colSums but it keeps giving me this type of
>> Error in rowSums(X == 1 & X == 1) :
>> 'x' must be an array of at least two dimensions
>> Thanks in advance!
>> 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