I have row values that end with a -# (# ranging from 4 - 8). I have a corresponding column that has values associated to each -# row.
I would like to use dplyr to transpose my df so the -3 rows turn into column fields and the number of corresponding values from other variables (columns) be added to each column given it's 'title' (-4, -5, etc.)
I used dplyr package to move my rows to column headers but cannot seem to get the right output.
head(MFP)
PART_RMV_DT RMV_MFR_PART_NO RMV_LRU_TSO_TM RMV_LRU_TSR_TM LRU
1 2017-06-25 828300-5 MFP
9 2016-01-11 828300-5 17500 17500 MFP
17 2015-12-27 828300-5 16698 12193 MFP
19 2018-11-30 828300-5 40738 17494 MFP
21 2016-09-19 828300-5 25107 13528 MFP
23 2016-11-17 828300-5 35281 35281 MFP
t <- as.data.frame.matrix(xtabs(RMV_LRU_TSO_TM~RMV_MFR_PART_NO, MFP_df))
Error in Summary.factor(c(4268L, 472L, 3342L, 17L, 1L, 1L, 2834L, 5421L, :
‘sum’ not meaningful for factors
If I have 4 different groups of values in my column based on -#, I would like to move those values into columns and pull the associated values from other columns below each one of those -# columns.