[R] Table help

João Gama jgama at liacc.up.pt
Wed Sep 26 19:56:09 CEST 2001


Hi,
A quick question:
I have to vectors, say ar1 and ar2

> ar1
    [1] "a" "c" "c" "a"
    attr(,"levels")
    [1] "a" "b" "c"

> ar2
    [1]  TRUE  TRUE FALSE  TRUE

> table(ar1, ar2)
       ar2
ar1 FALSE TRUE
  a     0    2
  c     1    1


I would like to obtain:

    T    F
a  2    0
b  0    0
c  1    1

The problem seems to be that level "b" in ar1 doesn't appear in ar1.
and Function "table" doesn't have any drop.unused.levels parameter.

Thanks
Joao Gama


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list