I am trying to take a very large and messy dataset, melt the data, then dcast it. I keep running into this "Aggregation function missing: defaulting to length" problem and I don't fully understand what the issue is. I have found a possible solution, but before I put my solution into production, I was hoping someone could explain what is going on.
code to build the DF:
z <- data.frame(ID = c("A","A","A","A","A","A","A","A"),
Disease = "Flu",variable = "event_date", value = "11/30/15")
what I thought would work
dcast(z, ID + Disease ~ variable)
But this code produces the Aggregation function missing: defaulting to length
and outputs:
ID Disease event_date
A Flu 8
when I use
dcast(z, ID + Disease ~ variable, fun.aggregate = levels)
I get the correct output of
ID Disease event_date
A Flu 11/30/15
but I'm not confident that using fun.aggregate = levels
is appropriate. Any advice or education would be much appreciated. Thanks!