【发布时间】:2021-02-12 02:36:48
【问题描述】:
我昨天问了一个问题,询问如何按名称访问嵌套列表的所有元素。 https://stackoverflow.com/a/64579426/9806500
是否有一个通用函数可以让我获得列表中更深的命名元素?特别是,我试图获取对 Slack 消息的回复的用户和时间戳,并且消息模式名称在消息的 replies 级别下重复使用 user 和 ts 成对指定谁和何时回复.我无法通过上面的 purrr 解决方案链接找到他们。不确定这是因为user 和ts 也是主要消息的元素名称,还是因为我无法通过使用~ purrr::map() 作为map() 中的映射器函数访问那么远的级别。
l <- list(folder_1 = list(
`msg_1-1` = list(type = "message",
subtype = "channel_join",
ts = "1585771048.000200",
user = "UFUNNF8MA",
text = "<@UFUNNF8MA> has joined the channel"),
`msg_1-2` = list(type = "message",
subtype = "channel_purpose",
ts = "1585771049.000300",
user = "UNFUNQ8MA",
text = "<@UNFUNQ8MA> set the channel purpose: Talk about xyz")),
folder_2 = list(
`msg_2-1` = list(type = "message",
subtype = "channel_join",
ts = "1585771120.000200",
user = "UQKUNF8MA",
text = "<@UQKUNF8MA> has joined the channel",
replies = list(list(user = "UABCDEFG8", ts = "1585771220.002200"),
list(user = "UGFEDCBA8", ts = "1585771220.022000")))))
谢谢!
【问题讨论】:
标签: r list tidyverse slack purrr