After spread function I would like to copy non-NA values to new column. Is there any way to let data that is not NA be copied to new columns?
Data
Serial_ID Repair_type Col1 Col2 Coln+1
ID_1 Warranty NA 02.02.2013 NA
ID_1 Normal NA 15.10.2011 12.01.2012
ID_2 Warranty 01-01-2013 NA NA
ID_2 Normal NA NA 18.12.2014
ID_n Normal NA 23.01.2014 NA
Desired result
Serial_ID Repair_type ColX (new) ColX2 (new) Col1 Col2
ID_1 Warranty 02.02.2013
ID_1 Normal 15.10.2011 12.01.2012
ID_2 Warranty 01-01-2013
ID_2 Normal 18.12.2014
ID_n Normal 23.01.2014
Please see the data and result on image below:
Hope that makes it clearer. Thank you in advance.
Long data before spread
Data:
COMM_VIN Si_DocDate COMM_Kind Cost
V1 2017-01-01 Normal 100
V1 2017-03-02 Warranty 200
V2 2015-04-04 Warranty 50
V2 2017-05-22 Warranty 100
V3 2004-05-22 Normal 150
V3 2016-06-01 Normal 250
I would like the dates of visits to the site to be moved to the column for the COMM_VIN variable depending on COMM_Kind
Results:
COMM_VIN COMM_Kind Col_ne1 Col_nen Cost(sum)
V1 Normal 2017-01-01 100
V1 Warramty 2015-04-04 2017-03-02 250
V2 Normal 2004-05-22 2016-06-01 400
V2 Warranty 2017-05-22 50
Sorry, I don't know how to add the table. Please see the attached picture: