tidyr: multiple unnesting with varying NA counts

前端 未结 2 744
孤城傲影
孤城傲影 2020-12-18 09:40

I\'m confused about some tidyr behavior. I can unnest a single response like this:

library(tidyr)

resp1 <- c(\"A\", \"B; A\", \"B\", NA, \"B\")
resp2 <         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 10:16

    In addition to Psidom answer: by default, unnest drops additional list columns (if row duplication is required).

    Use .drop = FALSE argument to keep other columns.

    Line unnest(resp1) %>% unnest(resp2) %>% unnest(resp3) becomes:

    unnest(resp1, .drop = FALSE) %>% unnest(resp2, .drop = FALSE) %>% unnest(resp3)
    

提交回复
热议问题