Re: [R] How to include NA's of a factor in table?

From: Jacques VESLOT <jacques.veslot_at_good.ibl.fr>
Date: Mon 10 Jul 2006 - 22:30:09 EST

fcv <- factor(c('a', NA, 'c'), exclude=NULL) table(fcv, exclude=NULL)



Jacques VESLOT

CNRS UMR 8090
I.B.L (2ème étage)
1 rue du Professeur Calmette
B.P. 245
59019 Lille Cedex

Tel : 33 (0)3.20.87.10.44
Fax : 33 (0)3.20.87.10.31

http://www-good.ibl.fr


Heinz Tuechler a écrit :
> 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)
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Jul 10 22:34:29 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 11 Jul 2006 - 00:17:18 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.