[R] question on creating a new logical variable

From: Renuka Sane <renukas_at_gmail.com>
Date: Fri 12 Aug 2005 - 01:57:40 EST

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
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
34 2

Is there a way to do this without making the new variable C?


Renuka Sane

	[[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Aug 12 02:01:33 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:47 EST