0

I have a data frame:

a=data.frame(matrix(1:30,ncol=5,byrow=1))

is there a way to extract the original vector (1:30) from the data frame as it exists?

I tried unlist(a), but it was ordered by columns, and not row.

1 7 13 19 25 2 8 14 20 26...

unlist(a, byrow=TRUE) does not work. There must be an efficient way to do this that I am missing, any suggestions

frank
  • 3,036
  • 7
  • 33
  • 65
  • 1
    You can use `c(t(a))` – Ronak Shah Jun 06 '19 at 13:00
  • There is an error in the code to create the data.frame. The first ) should be omitted. – G. Grothendieck Jun 06 '19 at 13:00
  • @Ronak thanks. As an aside, how do questions get flagged as duplicates? I did not see this question when I searched – frank Jun 06 '19 at 13:05
  • updated orig question – frank Jun 06 '19 at 13:06
  • 1
    @alex If anybody knows that this question has been asked before they can find that question and flag it as duplicate. Finding that question is sometimes not that easy as you need to know exactly which search terms will lead you to the exact post. In this case I knew this question existed so I marked it as duplicate of the original question. – Ronak Shah Jun 06 '19 at 13:12

0 Answers0