change data frame columns to rows

Posted by Sol Lago on Stack Overflow See other posts from Stack Overflow or by Sol Lago
Published on 2013-11-01T15:48:01Z Indexed on 2013/11/01 15:53 UTC
Read the original article Hit count: 149

Filed under:
|
|
|

Sorry if this is obvious: I found a lot of questions similar to mine but I can't figure it out for my own data. I have a data frame that looks like this:

A <- c(1,6)
B <- c(2,7)
C <- c(3,8)
D <- c(4,9)
E <- c(5,0)
df <- data.frame(A,B,C,D,E)
df
  A B C D E
1 1 2 3 4 5
2 6 7 8 9 0

And I need this:

df
   X1  
A  1   
A  6
B  2  
B  7
C  3  
C  8
D  4       
D  9
E  5  
E  0

Thanks!

© Stack Overflow or respective owner

Related posts about r

    Related posts about rows