Without having a reproducible example, it's hard to say, but you may want to look at ?t
example <- data.frame("sample"=c("RNA1","RNA2","RNA3"),"value"=rnorm(3,0,1))
example
sample value
1 RNA1 0.7666676
2 RNA2 0.6275869
3 RNA3 -2.7513690
t(example)
[,1] [,2] [,3]
sample "RNA1" "RNA2" "RNA3"
value " 0.7666676" " 0.6275869" "-2.7513690"
You could also look at the reshape2
package.
It kind of looks like you have your data in a list. Assuming you have your data in a list you could do the following:
example.list <- list("10848"=c("RNA1","RNA2","RNA3"),"3056"=c("RNA1","RNA2"))
cbind(unlist(example.list),names(unlist(example.list)))
[,1] [,2]
108481 "RNA1" "108481"
108482 "RNA2" "108482"
108483 "RNA3" "108483"
30561 "RNA1" "30561"
30562 "RNA2" "30562"