[R] question on creating a new logical variable

Paul Roebuck roebuck at odin.mdacc.tmc.edu
Thu Aug 11 18:42:57 CEST 2005


On Thu, 11 Aug 2005, Renuka Sane wrote:

> 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
>
> [SNIP]
>
> 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?

You mean something besides not explicitly creating it?

table(c(A, B) == 1)

----------------------------------------------------------
SIGSIG -- signature too long (core dumped)




More information about the R-help mailing list