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

我有一个从REST调用收到的嵌套列表.响应包括来自底层关系数据库的嵌套列表集.我想压扁列表以简化分析.我曾尝试遵循 purrr tutorial中的指导原则,但我无法让它发挥作用.

我的简化输入

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",hist3))
issue <- list(issue1,issue2)

我正在寻找扁平的输出

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

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

最适合我的):

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

解决方法

受@ Nate回答启发的另一个解决方案:
map_df(issue,as_tibble) %>% 
    mutate(issue_history = map(issue_history,as_tibble)) %>% 
    unnest()

# A tibble: 4 x 5
#     id    created  field from_string to_string
#  <chr>      <chr>  <chr>       <chr>     <chr>
#1   123 2017-11-08   type       issue       bug
#2   123 2017-11-08 status        open    closed
#3   124 2017-11-10   type       issue       bug
#4   124 2017-11-10   type         bug     issue

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...