Problem
I'm trying to append new columns of data to an existing dataframe. The dataframe constists of multiple rows and columns, the data I'm trying to append is just one row and it should be added to the first row of the existing dataframe.
data is a dataframe with 3000 rows and 20 columns and a is a dataframe with 1 row and 12 columns.
for (o in 1:length(a)) {
data[[1,(paste0(names(a)[o]))]]=a[o]
}
Error
replacing element in non-existent column
Expected result
I want to obtain a dataframe with 3000 rows and 32 columns, where the last 12 columns are missing values for the other rows, which I intend to populate later one by one.
I have already tried...
append(), cbind(), merge() with no success, so I came up with this loop but had no success either. I can't figure out where I'm making a mistake.