R: Unlist list to columns in dataframe

和自甴很熟 提交于 2019-12-25 18:25:56

问题


I have a data frame which is made of up:

Var1  Var2   Var3
a      b     nested list

Nested list =

 ####test:
           apple: a
           pear:   b
  ####test2:
             apple: a
             orange: c

Is there a simple way to turn the nested list in v3 of each row into further columns, with the list element names as the variable names and each list value in each cell? e.g.

Var1 Var2 Var3        apple pear orange
a    b    nested list   a   b    NULL

回答1:


maybe you are looking for tidyr::spread(). It is anyways hard to try other things without a reproducible example.



来源:https://stackoverflow.com/questions/51641404/r-unlist-list-to-columns-in-dataframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!