I have a data which looks like this :-
data_source zip date calories user price
compA 45768 18274 3500 abc 912.27
compB 33098 18274 3500 groups 981.28
compA 39104 18274 2500 ands 659.75
I would like to have wide format of data using dcast; Earlier it use to work, but now it does not.
data.table::dcast(zip + date + calories ~ data_source, value.var=c("user","price"), data=data)
As you can see the column in value.var
has character
and numeric
value both, and so I'm confused what to use in fun.aggregate
. So the data converted is defaulting to length
which is what I do not want. I just want the values as it is but in wide format. Thanks for your help.