Skip to content
Prev 42913 / 63424 Next

Problem with table

On 19/03/2012 17:01, Terry Therneau wrote:
You have not told us what you want!

Try

 >  table(as.factor(c(1,2,3,4,NA)), exclude=2, useNA='ifany')

    1    3    4 <NA>
    1    1    1    1

Note carefully how 'exclude' is defined:

  exclude: levels to remove from all factors in ?...?. If set to ?NULL?,
           it implies ?useNA="always"?.

As you did not specify a factor, 'exclude' was used in forming the 'levels'.
Most likely, feed table() a factor with the properties you want.