This is such a basic question, but I am stuck: The code is taken from here: https://www.geeksforgeeks.org/list-of-dataframes-in-r/
I have this list of dataframes of length 2.
# Create dataframe
df1 = data.frame(
y1 = c(1, 2, 3),
y2 = c(4, 5, 6)
)
# Create another dataframe
df2 = data.frame(
y1 = c(7, 8, 9),
y2 = c(1, 4, 6)
)
# Create list of data frame using list()
listOfDataframe = list(df1, df2)
Now I want that this list becomes a column in a data.frame
. As my list is of length 2, I thought the dataframe should have two rows as I want each dataframe to be essentially on one row.
So I try the following:
df_list_col = data.frame(a = 1:2, listOfDataframe)
But I get the following error:
Error in data.frame(a = 1:2, listOfDataframe) :
arguments imply differing number of rows: 2, 3
What am I missing here?