Insert list as dataframe column in R
In this article, we will discuss how to add a list as a column to dataframe in R Programming Language.
Creating dataframe for demonstration:
Now to add a list as a column, create a list with required values. Then, use the name of the data frame and the new column separated by $ and assign this to the list so created.
This will assign the list to the column name given and then add it to the dataframe.
Creating columns in such a way allows adding NA values where no data is required too. Just write NA for places where data is not there and the rest of the process is the same as above.