[R] reshape2's dcast() Adds NAs to Data Frame
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Thu Aug 9 03:21:18 CEST 2012
The explanation is that this is normal and consistent with behavior of factors in general. If you don't want that, it is common to work with character data instead of factors, only converting to factor when needed. In most cases I invoke read.table with the as.is=TRUE argument and delay converting to factors until I need them. Other people convert from factor to character and back to factor to get rid of unwanted factor levels on an as-needed basis.
---------------------------------------------------------------------------
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.
Rich Shepard <rshepard at appl-ecosys.com> wrote:
>On Wed, 8 Aug 2012, arun wrote:
>
>> The param factor has 54 levels. So, I guess the combinations that are
>not
>> present will record as NA.
>
> I noticed that but have not found an explanation.
>
> I'll work with the base data frame.
>
>Thanks,
>
>Rich
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list