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
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
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))
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.
We can load the data into a list
and unlist
data.frame(a = unlist(mget(ls(pattern = '^data\\d+$'))))