I have a group like so
group=c("year","reach", "treatment.long", "transect")
then later in my code I need to dcast()
my data based on the group
(note the group will be changing).
dcast(melted.data, year + reach + treatment.long + transect ~ stat, value.var="value")
How can I get the group
into the format year + reach + treatment.long + transect
?
Thank you
I adjusted it to
dcast(melted.data, as.formula(paste(paste( group, collapse=' + ' ), "~ stat")), value.var="value")
and am getting the error "Aggregation function missing: defaulting to length"