I have a question about upgrade values in a dataframe. The dataframe looks like this:
P1 P2 P3 P4 P5 P6
A 1 0 0 0 0 0
B 0 1 0 0 0 0
C 0 0 1 0 0 1
D 0 0 0 0 1 0
E 1 0 0 0 0 0
F 0 0 0 1 1 0
My problem is, that i want to upgrade some values by +1. Which means, that I have a variable P1_upgrade which contains the rows that need to be upgraded by +1. Can anyone help me with this problem? The final column must be like the below column:
> P1_upgrade <- "E"
> P3_upgrade <- "C"
> P5_upgrade <- c("D","D","F")
P1 P2 P3 P4 P5 P6
A 1 0 0 0 0 0
B 0 1 0 0 0 0
C 0 0 2 0 0 1
D 0 0 0 0 3 0
E 2 0 0 0 0 0
F 0 0 0 1 2 0