How can I create a new column "desc" based on the value of column "num"?
Here is my original dataset. a, b, c, d, e, and f are rownames.
Here is the output I am looking for. Notice that "desc" consists of the rownames of column "num". The rownames of num 2 are b and d; hence desc of num 2 is "Var : b, d." The rownames of num 3 are c, e, f; hence desc of num 3 is "Var : c, e, f."
Here is the code to create the dataset.
df <- data.frame(num=c(1, 2, 3, 4, 3, 3))
rownames(df) <- c("a", "b", "c", "d", "e", "f")

