transposing a large number of rows into a single column?

Viewed 57

I'd like to turn my rows into a single column. I tried with VBA but it doesn't go all the way (it crashes before). So I'm thinking of trying on R.

More precisely I have 193 columns and 4957 rows. So I would like to get one column of 956,701 rows. So I need an automatic code, not a formula that has to be adapted because it would take too long.

So just to make sure I've made myself clear, here's what I'd like to get for this little example:

1 2 3 4 5
6 7 8 9 10

1
2
3
4
5
6
7
8
9
10

Do you have any idea what code might solve my problem?

2 Answers

We can transpose and concatenate

newdf <- data.frame(col1 = c(t(df1)))

In R, it is very easy to do with melt(). If your data is in csv, use read_csv and use melt() and then write it back to CSV if needed.

Related