Is there a way to cast multiple values in R. Example
df <- data.frame(ID = c(1,1,1,2,2,2), Cat = c("a","b","c","a","b","c"), Spend = c(8,2,4,9,1,2), Sales = c(1,8,6,6,9,1))
Above is the dataframe, so we need to cast 2 numeric values
Expected output
ID a_Spend b_Spend c_Spend a_Sales b_Sales c_Sales
1 8 2 4 1 8 6
2 9 1 2 6 9 1