R

How to unlist a nested list in R

Here is a simple tutorial on how to unlist a nested list with the help of R. Problems may appear when nested lists are a different length for each record. For example, chat sessions and corresponding lists of conversations that differ in length.

Here is all code altogether and additional explanations below.

 



Create a simple data frame with a nested list.

With the help of package data.table function rbindlist create a data frame with an unlisted nested list column. Add id column, which is a key that shows the previous data frame row.

Create a row id column in the first data frame.

Join the first data frame and unlisted list data frame together.

Here is another post dedicated to lists.

0 comments on “How to unlist a nested list in R

Leave a Reply

Your email address will not be published. Required fields are marked *