Given the following data.frame df
:
Typ1 Typ2
1 0
0 1
1 0
And want to replace the values in each column where the value is set to 1 (is there a smarter possibility as the following?):
df["Typ1"][df["Typ1"] == 1]<-"Typ1"
df["Typ2"][df["Typ2"] == 1]<-"Typ2"
And merge the columns to:
Typ
"Typ1"
"Typ2"
"Typ1"