Skip to content
Back to formatted view

Raw Message

Message-ID: <1115a2b0050811092723b52196@mail.gmail.com>
Date: 2005-08-11T16:27:57Z
From: Wensui Liu
Subject: question on creating a new logical variable
In-Reply-To: <f7dc8e940508110857320c9b3d@mail.gmail.com>

table(ifelse(A==2&B==3, TRUE, FALSE))


On 8/11/05, Renuka Sane <renukas at gmail.com> wrote:
> I think there was an incomplete mail that was accidently sent by me. I
> apologize for the inconvenience. Here is the full text.
> 
> I have two variables.
> A <- rep(c(1:9), 2)
> B <- rep(c(2:10),2)
> 
> I want to know the the value for
> A==1 and B==1
> 
> If I do A== 1 | B==1, I get
> FALSE TRUE
> 16 2
> This is incorrect.
> 
> Similarly table(A==1) +table(B==1) reports an error as the arrays are non
> conformable.
> 
> To solve the problem I therefore create a new variable
> C <- c(A, B)
> and then do table(C==1) which gives me
> FALSE TRUE
> 34 2
> 
> Is there a way to do this without making the new variable C?
> 
> Thanks,
> Renuka
> 
> --
> Renuka Sane
> http://www.nyx.net/~rsane
> 
>         [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 


-- 
WenSui Liu
(http://statcompute.blogspot.com)
Senior Decision Support Analyst
Cincinnati Children Hospital Medical Center