小编rgu*_*avs的帖子

哪个是使用tidyverse工具压缩从关系数据库派生的嵌套列表的最佳方法?

我有一个从REST调用收到的嵌套列表.响应包括来自底层关系数据库的嵌套列表集.我想将列表展平以简化分析.我试图遵循purrr教程中的指导原则,但我无法让它工作.

我的简化输入

hist1 <- list(field="type", from_string ="issue", to_string="bug")
hist2 <- list(field="status", from_string ="open", to_string="closed")
hist3 <- list(field="type", from_string ="bug", to_string="issue")
issue1 <- list(id="123", created = "2017-11-08", issue_history = list(hist1, hist2))
issue2 <- list(id="124", created = "2017-11-10", issue_history = list(hist1, hist3))
issue <- list(issue1, issue2)
Run Code Online (Sandbox Code Playgroud)

我正在寻找扁平的输出:

id  created    type   from_string  to_string
123 2017-11-08 type   issue        bug
123 2017-11-08 status open         closed
123 2017-11-10 type   bug          issue
Run Code Online (Sandbox Code Playgroud)

为此构建scable逻辑的最佳方法是什么?

最适合我的):

  • 来自tidyverse的工具
  • 易于维护的代码
  • 不必扩展数百万个问题,即性能和内存不是关键要素

r nested-lists purrr tidyverse

7
推荐指数
2
解决办法
301
查看次数

标签 统计

nested-lists ×1

purrr ×1

r ×1

tidyverse ×1