Complete the code to nest the data frame by the 'group' column.
library(dplyr) library(tidyr) data <- data.frame(group = c('A', 'A', 'B', 'B'), value = 1:4) nested_data <- data %>% group_by(group) %>% [1](data = c(value))
The nest() function groups data into nested tibbles by the specified columns.
Complete the code to unnest the nested data frame column 'data'.
library(tidyr) nested_data <- tibble(group = c('A', 'B'), data = list(tibble(value = 1:2), tibble(value = 3:4))) unnested_data <- nested_data %>% [1](data)
The unnest() function expands list-columns back into regular rows.
Fix the error in the code to correctly nest the data frame by 'category'.
library(tidyr) data <- data.frame(category = c('X', 'X', 'Y'), score = c(10, 20, 30)) nested <- data %>% [1](category, data = c(score))
The nest() function is used to group data into nested tibbles by the specified columns.
Fill both blanks to nest the data frame by 'team' and nest the 'points' column.
library(tidyr) data <- data.frame(team = c('Red', 'Red', 'Blue'), points = c(5, 7, 8)) nested <- data %>% group_by([1]) %>% [2](data = c(points))
First, group by the 'team' column, then use nest() to nest the 'points' column.
Fill all three blanks to unnest the nested data frame and select the 'group' and 'value' columns.
library(tidyr) nested_data <- tibble(group = c('A', 'B'), data = list(tibble(value = 1:2), tibble(value = 3:4))) unnested <- nested_data %>% [1](data) %>% select([2], [3])
Use unnest() to expand the 'data' column, then select the 'group' and 'value' columns.