[R] reshape2: Lost Values Between melt() and dcast()

Rich Shepard rshepard at appl-ecosys.com
Mon Oct 31 18:41:39 CET 2011


On Mon, 31 Oct 2011, Justin Haynes wrote:

> However, the dcast calls that "failed" can be helpful for determining the
> source of your error.  I'd look at the outputs of those two dcast calls
> and find cells where the length is > 1.  Those are duplicated entries in
> your initial data.frames (when I've run into this is was usually due to NA
> values somewhere unexpected).

Justin,

   I'll have to dig in the docs to see how to examine specific rows in the
original data frames because I cannot find where duplicate entries were
generated.

   In the dcast() results for the two problem data frames I found 1 row with
a value of 2 in one and 8 rows each with a value of 2 in the other. When I
look at the original database table, only one row is present for each of the
9. There are about 47.5K rows in the original R data frame so going through
them one at a time is a problem.

   Have you any suggestion on how to examine the data frame and the melted
data frame to see where the problems might be?

Thanks,

Rich



More information about the R-help mailing list