Greetings to all,
You see, I have a large dataframe, and the names of the columns have a format type "XXX_YYY_ZZZ", being able to take XXX, YYY or ZZZ different categories / factors. I would like to make a dataframe of only 4 columns, being the columns "XXX", "YYY", "ZZZ" and the values of the columns. previous.
I was wondering if anyone knows any simple way to do all this.
For example, the current data frame looks like this:
"CYT_CD40L_exp1" | "MEMB_QVD_exp1" | "ORG_FasL_exp3"
0 | 2 | 4 1 | 3 | 5
and I would like to convert the table to:
Value | "XXX" | "YYY" | "ZZZ"
0 | "CYT" | "CD40L" | "exp1"
1 | "CYT" | "CD40L" | "exp1"
2 | "MEMB" | "QVD" | "exp1"
3 | "MEMB" | "QVD" | "exp1"
4 | "ORG" | "FasL" | "exp3"
5 | "ORG" | "FasL" | "exp3"
I know I can separate the names of the columns with strsplit(colnames(df), sep"_")[y]
, but it is very tedious to sort all the values.
I hope I have explained myself sufficiently ^^ U. Thank you very much.