Skip to content

Table help

2 messages · Peter Dalgaard, João Gama

#
Jo?o Gama <jgama at liacc.up.pt> writes:
ar1 is not a factor there (giving it a levels attribute won't make it
a factor). Try
ar2
ar1 FALSE TRUE
  a     0    2
  b     0    0
  c     1    1
#
Hi,
A quick question:
I have to vectors, say ar1 and ar2
[1] "a" "c" "c" "a"
    attr(,"levels")
    [1] "a" "b" "c"
[1]  TRUE  TRUE FALSE  TRUE
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._