Introduction: I work in a strict environment where I can not install any more packages. I have access to dcast(), xtabs(), reshape() from {stats}. I don't have access to tydr, reshape nor reshape2 packages.
Now to the problem: I have a summarized data frame with 4 columns names cust_id, merchant_group, sum and max that looks like:
cust_id merchant_group sum max
<int> <chr> <dbl> <dbl>
1 495 AIRLINE 45493 4950
2 495 AUTO RENTAL 3104 1000
3 495 CLOTHING STORES 20928 3140
4 495 DEPARTMENT STORES 1082 495
5 495 DRUG STORES 482 165
I want to reshape it into wide form that will look like:
cust_id AIRLINE AUTO RENTAL CLOTHING STORES DEPARTMENT STORES DRUG STORES
495 45493 3104 20928 1082 482
495 4950 1000 3140 495 165
I have tried functions such as:
xtabs(sum~cust_id+merchant_group, data=my.data)
reshape(my.data, idvar = "cust_id", timevar = "merchant_group", direction = "wide")
But doesn't solve my problem. Thank you in advance for your time.