Search code examples
rdataframemultiple-columnsrowsdata-cleaning

How can I create a one-column dataframe containing all numeric values of a dataframe with several columns?


Sorry for the basic question here!

I am working the following type of dataset:

data <- data.frame(a=c(1,2,3), b=c(2,3,4), c=(10,11,12))

I am trying to turn it into a new data frame where there is only one column, containing all of these values in individual rows, i.e. a=c(1,2,3,2,3,4,10,11,12)

What function should I use to arrive at this output?

All the best,

Cameron


Solution

  • You can do data.frame(a = unlist(data)).