I have a data.frame that is almost completely blank, but each line has one value. How can I use a vector or other r-language approach to combine the contents of each line into one vector?
sample data:
raw_data <- structure( list( col1 = c("", "", "", "", ""), col2 = c("", "", "", "", ""), col3 = c("", "", "", "", ""), col4 = c("", "", "", "Millburn - Union", ""), col5 = c("", "", "Cranston (aka Garden City Center)", "",""), col6 = c("", "", "", "", ""), col7 = c("", "", "", "", ""), col8 = c("", "", "", "", "Colorado Blvd"), col9 = c("", "", "", "", ""), col10 = c("", "", "", "", ""), col11 = c("Palo Alto", "Castro (aka Market St)", "", "", "") ), .Names = c("col1", "col2", "col3", "col4", "col5", "col6", "col7", "col8", "col9", "col10", "col11"), row.names = c(5L, 4L, 3L, 2L, 1L), class = "data.frame" )
This is what I tried, but it fails as it returns a 2-dimensional matrix instead of the desired vector:
raw_data$test <- apply(raw_data, MAR=1, FUN=paste0)