简体   繁体   English

从R列表中提取属性

[英]Extract attributes from R list

I fear I'm missing something obvious but . 我担心我会遗漏一些显而易见的东西。 . . I have a list in R with structure 我在R中有一个结构列表

List of 752
 $ : Named chr "金銀"
  ..- attr(*, "names")= chr "名詞"
 $ : Named chr "吹替"
  ..- attr(*, "names")= chr "名詞"
 $ : Named chr "献言"

It's easy enough to get the top level of the list with unlist(my_object). 使用unlist(my_object)很容易获得列表的顶级。 But how can I capture the attributes? 但是我如何捕获属性? I can use unlist(attributes(my_object[[n]])) for each element n. 我可以为每个元素n使用unlist(属性(my_object [[n]]))。 But surely there's a quick way to get this into a data frame. 但肯定有一种快速的方法可以将其纳入数据框架。 What am I missing? 我错过了什么?

lapply(yourlist, attributes)

attributes函数应用于列表中的每个元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM