[R] How to include NA's of a factor in table?
Heinz Tuechler
tuechler at gmx.at
Mon Jul 10 14:23:00 CEST 2006
Dear All,
Is there a better way to include NA's of a factor in the output of table()
than using as.character()?
Admittedly, I do not understand the help page for table concerning the
exclude argument applied to factors. I tried in different ways, but could
not get NA to be included in the table, if not using as.character() (see
example).
Greetings,
Heinz
## example
fcv <- factor(c('a', NA, 'c'))
table(fcv) # shows a, c
table(fcv, exclude='a') # shows c
table(fcv, exclude="") # shows a, c
table(fcv, exclude=NULL) # shows a, c
table(as.character(fcv), exclude=NULL) # shows a, c, NA
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status Patched
major 2
minor 3.1
year 2006
month 07
day 01
svn rev 38471
language R
version.string Version 2.3.1 Patched (2006-07-01 r38471)
More information about the R-help
mailing list