r - reshape2: dcast margin behavior -
i'm writing ask understanding behavior of reshape2::dcast confusing me. when run following 4 lines (the example dataset 'french_fries' comes 'reshape2' package), 3 data.frames different lengths, whereas expect them identical except permuted rows , columns:
library('reshape2') ff_d <- melt(french_fries, id=1:4, na.rm=true) # "french_fries" included in 'reshape2' package = dcast(ff_d, treatment + subject ~ variable, mean, margins=t) # think these data.frames long paste directly question b = dcast(ff_d, subject + treatment ~ variable, mean, margins=t) d = merge(a, b, = t) # expecting 'd' , 'a' (and 'b') identical.
are variables on left side of formula being treated nested, margins of second variable within levels of first? i'd grateful insights, , particularly explanations of how 3 types of margins using 1 function call, e.g. treament=all subject, subject=all treatment, , both=all.
many thanks!
Comments
Post a Comment