How to avoid NA columns in dcast() output?

后端 未结 4 1934
名媛妹妹
名媛妹妹 2021-01-21 05:43

How can I avoid NA columns in dcast() output from the reshape2 package?

In this dummy example the dcast() o

4条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 06:41

    library(dplyr)
    library(tidyr)
    iris %>%
      filter(!is.na(Species2)) %>%
      group_by(Species, Species2) %>%
      summarize(freq = n()) %>%
      spread(Species2, freq)
    

提交回复
热议问题