How to create a label variable from a binary matrix with multiple columns
Hello! I am trying to get a label variable from a binary matrix (df). The df matrix has multiple columns (n=981), and I want to get a categorical variable with 3 especific labels based on all the df columns.
First, I created a small matrix and tried with the next code:
my_sample_col <- data.frame(sample = rep(c("A", "B", "C"), c(2,3,4)))
row.names(my_sample_col) <- colnames(df)
my_sample_col
However, these results are not the correct labels for each column of the df matrix.
Correct labels must be as below:
I was wondering if someone could help me to fix this error. Finally, I would like to get a categorical variable with 3 especific labels based on all the df columns (n=981)
Please, I would be very grateful by their awesome help.
• 39 views
Read more here: Source link