Reputation: 721
In collapsing rows into a list with nest(), the output is not what I would expect. The result is a list like this:
list(X1 = c("..."))
I would have expected:
c("...")
An example using the CNN dataset
library(tidyverse)
library(readr)
test <- read_tsv("cnn/stories/0a0a4c90d59df9e36ffec4ba306b4f20f3ba4acb.story",
col_names = FALSE)
test2 <- test %>%
nest(X1, .key = articles)
EDIT: So, if I wanted a solution that gives me the output of
c("...")
I would have to do :
test3 <- test %>%
do(X1 = unique(unlist(.$X1)))
Upvotes: 0
Views: 51
Reputation: 5263
From the documentation page for tidyr::nest
(emphasis mine):
nest()
creates a list of data frames containing all the nested variables: this seems to be the most useful form in practice.
Upvotes: 1