I have a dataframe like this:
> dput(df_before)
structure(list(ID = 1:4, White = c(1L, 0L, 0L, 0L), Black = c(0L,
1L, 0L, 0L), Asian = c(0L, 0L, 1L, 1L)), class = "data.frame", row.names = c(NA,
-4L))
Right now the 'Race' variable is encoded as a dummy variable, but I would like it to look like this:
> dput(df_after)
structure(list(ID = 1:4, Race = c("White", "Black", "Asian",
"Asian")), class = "data.frame", row.names = c(NA, -4L))