Re: [R] Counting two factors at the same time

2010-01-22 Thread David Winsemius
On Jan 22, 2010, at 2:07 PM, Fabrice DELENTE wrote: Here's another R-way: lets<-factor(c( 'A', 'B', 'A', 'C', 'B', 'D', 'B')) # you did say they were factors, right? nums <- factor(c('1', '2', '2', '3', '2', '2', '3')) lets=="B" [1] FALSE TRUE FALSE FALSE TRUE FALSE TRUE sum(lets=="B"

Re: [R] Counting two factors at the same time

2010-01-22 Thread Fabrice DELENTE
> Here's another R-way: > > > lets<-factor(c( 'A', 'B', 'A', 'C', 'B', 'D', 'B')) > # you did say they were factors, right? > > nums <- factor(c('1', '2', '2', '3', '2', '2', '3')) > > lets=="B" > [1] FALSE TRUE FALSE FALSE TRUE FALSE TRUE > > sum(lets=="B" & nums=="2") > [1] 2 Thanks very muc

Re: [R] Counting two factors at the same time

2010-01-22 Thread David Winsemius
On Jan 22, 2010, at 1:58 PM, Fabrice DELENTE wrote: Try this; f <- c( 'A', 'B', 'A', 'C', 'B', 'D', 'B') n <- c('1', '2', '2', '3', '2', '2', '3') table(paste(f, n)) Thanks for the incredibly fast answer! I'll give this a shot! Here's another R-way: > lets<-factor(c( 'A', 'B', 'A', 'C',

Re: [R] Counting two factors at the same time

2010-01-22 Thread Fabrice DELENTE
> Try this; > > > f <- c( 'A', 'B', 'A', 'C', 'B', 'D', 'B') > > n <- c('1', '2', '2', '3', '2', '2', '3') > > table(paste(f, n)) Thanks for the incredibly fast answer! I'll give this a shot! -- Fabrice DELENTE __ R-help@r-project.org mailing list ht

Re: [R] Counting two factors at the same time

2010-01-22 Thread Henrique Dallazuanna
Try this; > f <- c( 'A', 'B', 'A', 'C', 'B', 'D', 'B') > n <- c('1', '2', '2', '3', '2', '2', '3') > table(paste(f, n)) On Fri, Jan 22, 2010 at 4:51 PM, Fabrice DELENTE wrote: > Hello. > > I'm trying to count string data that correspond to a given > condition in two factors of the same length. >

[R] Counting two factors at the same time

2010-01-22 Thread Fabrice DELENTE
Hello. I'm trying to count string data that correspond to a given condition in two factors of the same length. For example, I have one factor [ 'A', 'B', 'A', 'C', 'B', 'D', 'B' ] and another is [ '1', '2', '2', '3', '2', '2', '3' ] I'd like to count the occurences of 'B' and '2' (so in my e