In R write list with several elements to data.frame

后端 未结 4 355
自闭症患者
自闭症患者 2021-01-29 05:51

I have a named list whose each element is a character vector. I want to write this list into a single dataframe where I have two columns, one with the name of the character vect

4条回答
  •  走了就别回头了
    2021-01-29 06:07

    I'm wondering if stack provides the functions you need (using the example of Henrik)

    ll <- list(x1 = c("a", "b", "c"), x2 = c("d", "e"))
    stack(ll)
    #-------
      values ind
    1      a  x1
    2      b  x1
    3      c  x1
    4      d  x2
    5      e  x2
    

提交回复
热议问题