You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this ever gets implemented, may I also suggest documenting the feature better than the original reshape2::dcast and adding examples.
This example from SO is pretty nice to show what it's supposed to look like (although I'm not sure what the merged result should look like): https://stackoverflow.com/questions/35167010/reshape2-dcast-margin-behavior
I like that this example switches the order of subject and treatment to show how the margins change.
Code example for posterity:
library('reshape2')
ff_d<- melt(french_fries, id=1:4, na.rm=TRUE)
a= dcast(ff_d, treatment+subject~variable, mean, margins=T)
b= dcast(ff_d, subject+treatment~variable, mean, margins=T)
d= merge(a, b, all=T) # I was expecting 'd' and 'a' (and 'b') to be identical.
This is one of those things that could be extremely useful for reporting, but it's probably not on many people's radars.
dcast, when called with margins arg, could possibly just call grouping sets, which are computing exactly what margin arguments is about. The only missing piece AFAIR is that row totals are not part of the grouping sets, so that would have to be additionally handled.
Submitted by: Arun ; Assigned to: Nobody; R-Forge link
The 'dcast' version of 'data.table' has everything implemented except for 'margins' argument.
The text was updated successfully, but these errors were encountered: