Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-17 Thread Stephen Politzer-Ahles
$Col2greaterthan5 - dataset$Col2 5 # Cross-tabulate xtabs(~ Col1 + Col2greaterthan5, dataset) Message: 2 Date: Sun, 16 Sep 2012 03:41:45 -0700 (PDT) From: SirRon thechrist...@gmx.at To: r-help@r-project.org Subject: [R] Count based on 2 conditions [Beginner Question] Message-ID: 1347792105574-4643282.p

[R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread SirRon
Hello, I'm working with a dataset that has 2 columns and 1000 entries. Column 1 has either value 0 or 1, column 2 has values between 0 and 10. I would like to count how often Column 1 has the value 1, while Column 2 has a value greater 5. This is my attempt, which works but doesn't seem to be

Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread Uwe Ligges
On 16.09.2012 12:41, SirRon wrote: Hello, I'm working with a dataset that has 2 columns and 1000 entries. Column 1 has either value 0 or 1, column 2 has values between 0 and 10. I would like to count how often Column 1 has the value 1, while Column 2 has a value greater 5. This is my attempt,

Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread Rui Barradas
Hello, Since logical values F/T are coded as integers 0/1, you can use this: set.seed(5712) # make it reproducible n - 1e3 x - data.frame(A = sample(0:1, n, TRUE), B = sample(0:10, n, TRUE)) count - sum(x$A == 1 x$B 5) # 207 Hope this helps, Rui Barradas Em 16-09-2012 11:41, SirRon

Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread arun
:41 AM Subject: [R] Count based on 2 conditions [Beginner Question] Hello, I'm working with a dataset that has 2 columns and 1000 entries. Column 1 has either value 0 or 1, column 2 has values between 0 and 10. I would like to count how often Column 1 has the value 1, while Column 2 has a value

Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread Peter Ehlers
On 2012-09-16 05:04, Rui Barradas wrote: Hello, Since logical values F/T are coded as integers 0/1, you can use this: set.seed(5712) # make it reproducible n - 1e3 x - data.frame(A = sample(0:1, n, TRUE), B = sample(0:10, n, TRUE)) count - sum(x$A == 1 x$B 5) # 207 Another way:

Re: [R] Count based on 2 conditions [Beginner Question]

2012-09-16 Thread David Winsemius
On Sep 16, 2012, at 3:41 AM, SirRon wrote: Hello, I'm working with a dataset that has 2 columns and 1000 entries. Column 1 has either value 0 or 1, column 2 has values between 0 and 10. I would like to count how often Column 1 has the value 1, while Column 2 has a value greater 5. This