I have a data frame in R that looks like:
Data<-
RefId Status Year PS Score Price Code StatusID
IU-1 Approved 2020 - - 23 FT
IU-1 Cancel 2020 - - 21 CT
IU-2 Approved 2020 - NA 13 FT
IU-3 Approved 2019 NA - 40 FT
I need to count the unique RefID whose Status is approved and count of each -, NA and Not Null values of variables starting from column 4 group by year.
Where 1st row corresponding to the year value have the unique count of RefID below that row it would be sum of count or respective variables.
Required output format-
Year Unique_Count PS Score Price Code StatusID
2020 2 NA NA NA NA
NA 0 0 1 0 0
Having "-" 2 2 1 0 0
Not Null 2 0 0 2 2
2019 1 NA NA NA NA
NA 1 1 0 0 0
Having "-" 1 0 1 0 0
Not Null 2 0 0 1 1