What are list-columns and nested data frames in R, and when are they useful?

Quick Overview

Asks what list-columns and nested data frames are in R and when to use them. Tests understanding of how data frames store columns, nesting and unnesting with tidyr, fitting per-group models with purrr, and the practical pitfalls of the structure.

What are list-columns and nested data frames in R, and when are they useful?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

What are list-columns and nested data frames in R, and when are they useful? ```hint What a column has to be Check what R actually requires of a data frame's columns. Is a list a vector, and does it have a length? ``` ```hint Where per-group results go Think of a task you would otherwise write as `split()` followed by `lapply()`. Where do the per-group inputs and outputs live afterwards, and how do they stay matched to their group? ``` ### What a Strong Answer Covers - What a list-column is and why a data frame can hold one - How nesting and unnesting work in `tidyr` - The per-group workflow with `purrr`, including how results get back into ordinary columns - Concrete cases where the structure helps, and cases where it only adds complexity - Practical pitfalls such as base `data.frame()` behavior, saving to flat files and memory use ### Follow-up Questions - After fitting one model per group, how do you get a tidy table of coefficients out of the list-column of models? - How would you turn a column of JSON responses with different shapes into ordinary columns? - What happens to a row whose list entry is empty when you unnest it, and how do you keep it? - When would you choose `group_by()` with `summarise()`, or base `split()` with `lapply()`, instead?

Overview: Asks what list-columns and nested data frames are in R and when to use them. Tests understanding of how data frames store columns, nesting and unnesting with tidyr, fitting per-group models with purrr, and the practical pitfalls of the structure.

PracHub logo
General
Nov 24, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

What are list-columns and nested data frames in R, and when are they useful?

What a Strong Answer Covers Guidance

  • What a list-column is and why a data frame can hold one
  • How nesting and unnesting work in tidyr
  • The per-group workflow with purrr , including how results get back into ordinary columns
  • Concrete cases where the structure helps, and cases where it only adds complexity
  • Practical pitfalls such as base data.frame() behavior, saving to flat files and memory use

Follow-up Questions Guidance

  • After fitting one model per group, how do you get a tidy table of coefficients out of the list-column of models?
  • How would you turn a column of JSON responses with different shapes into ordinary columns?
  • What happens to a row whose list entry is empty when you unnest it, and how do you keep it?
  • When would you choose group_by() with summarise() , or base split() with lapply() , instead?