Changing the dataframe in R

I have the following dataframe (part of it)

|Customer|Country|Month|Year|Sales Status|Type|Total
|Thin Client L|Germany|Jan|2015|Plan|Units|1930.38|
|Thin Client L|Germany|Jan|2015|Plan|Cost of Sales|9170.59|
|Thin Client L|Germany|Jan|2015|Plan|Turnover|9311.61|
|Thin Client L|Germany|Jan|2015|Actual|Units|2533.76|
|Thin Client L|Germany|Jan|2015|Actual|Cost of Sales|11623.7|
|Thin Client L|Germany|Jan|2015|Actual|Turnover|11523.6|
|Thin Client L|Germany|Jan|2015|Approved|Units|1930.38|
|Thin Client L|Germany|Jan|2015|Approved|Cost of Sales|9170.59|
|Thin Client L|Germany|Jan|2015|Approved|Turnover|9311.61|
|Thin Client L|Germany|Feb|2015|Plan|Units|6825|
|Thin Client L|Germany|Feb|2015|Plan|Cost of Sales|27301.1|
|Thin Client L|Germany|Feb|2015|Plan|Turnover|39900|
|Thin Client L|Germany|Feb|2015|Approved|Units|6825|
|Thin Client L|Germany|Feb|2015|Approved|Cost of Sales|27301.1|
|Thin Client L|Germany|Feb|2015|Approved|Turnover|39900|

And I would love to have it looking like this

Plan Df
|Customer|Country|Month|Year|Units|Cost Of Sales|Turnover|
|Thin Client L|Germany|Jan|2015|1930.38|9170.59|9311.61|

Same with 'Actual' and 'Approved'
If there are no values for the combination, something around 'NA' would be lovely, but that's purely optional.

I would use this : Pivot data from long to wide — pivot_wider • tidyr

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.