I'm trying to use R to create a new dynamic pivot table.
dt <- [login to view URL](TableIn)
PivotTable1 <- dcast(dt, A + B + C + D ~E, [login to view URL] = "F")
PivotTable <- PivotTable1[c("B","P",“C”,"A","G")]
From this function, I'm able to create a new dynamic pivot table.
Right now, I would like to set a order on this new table likes third function above.
But issue is that I'm not able to set order for columns newly generated from dcast function such as G & P.
For example, we can generate columns "B",“C”,"G","A" under case 1 while generating columns "B",“C”,"P","A", under case 2. Then it shows me error message. Because case 1 doesn't include column "P". However, we set a order for column "P" in third function.
Right now, I need a function which is able to generate all columns by particular order. If some columns are not available in some inputs, other columns are still supposed to be in order.