0

I have three columns with the same data type.

data1$a

a
123
123
311

data2$a

a
231
461
456

data3$a

a
161
161
169

My desired goal is this.

newdataframe

a
123
123
311
123
123
311
161
161
169
RL_Pug
  • 697
  • 7
  • 30
  • 2
    Try `df <- data.frame(a=c(data1$a,data2$a,data3$a))` – Duck Sep 29 '20 at 21:41
  • 1
    Does this answer your question? [Convert a list of data frames into one data frame](https://stackoverflow.com/questions/2851327/convert-a-list-of-data-frames-into-one-data-frame) – camille Sep 29 '20 at 21:47

3 Answers3

1

Probably there is a better way to do it but to big problems simple solutions haha.

lst <- list(data1$a, data2$a, data3$a) #Create a list with your data

df <- data.frame(unlist(lst)) #Unlist all the lists created and create a data frame.

Or just like @Duck said:

df <- data.frame(a=c(data1$a,data2$a,data3$a))
Enrique
  • 842
  • 1
  • 9
  • 21
1

If the rest of your dataframe also contain the same columns as the first one you can try

new_df <- rbind(data1, data2, data3)

to merge them together.

portablemaex
  • 115
  • 6
0

We can load the data into a list and unlist

data.frame(a = unlist(mget(ls(pattern = '^data\\d+$'))))
akrun
  • 874,273
  • 37
  • 540
  • 662