Skip to content
Prev 306193 / 398525 Next

Strange data frame behavior

This has nothing to do with data frames and everything to do with how factors behave.

The levels of a factor are not necessarily linked with the content of the factor. For example, a factor representing "Male" and "Female" has both of those levels even if all the data in a subset represents "Male".

If you want traces of those eliminated values removed, consider using character data rather than factors. In particular, using the as.is=TRUE or the stringsAsFactors= FALSE argument to read.table and similar functions will prevent automatic generation of factors. You can then choose when to convert to factor after you have manipulated your data.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Raoni Rodrigues <caciquesamurai at gmail.com> wrote: