I can't find a fast way to convert my data frame into a vector composed of the df columns. I have a df made of x rows per y columns and I'd like to have a vector or a list or a df (the class doesn't really matter) that is x per y rows and only 3columns of which one is that of the rownames (repeated for every column), the second is that of the listed values(data) and the third is that of the repeated col names. To better explain, I want to go from this
c1 | c2 | c3 | |
---|---|---|---|
n1 | 0.1 | 0.2 | 0.3 |
n2 | 0.4 | 0.5 | 0.6 |
n3 | 0.7 | 0.8 | 0.9 |
to this
values | colname | |
---|---|---|
n1 | 0.1 | c1 |
n2 | 0.4 | c1 |
n3 | 0.7 | c1 |
n1 | 0.2 | c2 |
n2 | 0.5 | c2 |
n3 | 0.8 | c2 |
Is there a fast way to manipulate this dataframe or the only way is to grab column by column and rbind()
?