整洁的巢()意外输出

tidy nest() unexpected output

在使用 nest() 将行折叠成列表时,输出不是我所期望的。结果是这样的列表:

list(X1 = c("..."))

我本以为:

c("...")

使用 CNN dataset

的示例
library(tidyverse)
library(readr)

test <-    read_tsv("cnn/stories/0a0a4c90d59df9e36ffec4ba306b4f20f3ba4acb.story", 
             col_names = FALSE)

test2 <- test %>%
  nest(X1, .key = articles)

编辑:所以,如果我想要一个能给我输出

的解决方案

c("...")

我必须这样做:

test3 <- test %>% 
  do(X1 = unique(unlist(.$X1)))

来自 tidyr::nest 的文档页面(强调我的):

nest() creates a list of data frames containing all the nested variables: this seems to be the most useful form in practice.