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"
> 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
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',
> 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
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.
>
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
6 matches
Mail list logo