How to count the number of T/F observations in chain functions using dplyr or base R?

后端 未结 1 1737
再見小時候
再見小時候 2021-01-24 15:19

Suppose I have a tbl_df called pokemons like this:

      X.                  Name Type.1 Type.2 Total    HP Attack Defense Sp..Atk Sp..Def Speed Gen         


        
相关标签:
1条回答
  • 2021-01-24 16:04

    We can do

    summaryStats_byType1  <-  pokemons %>%
                                group_by(Type.1) %>%
                                summarise(count = n(),
                                    averageTotal = mean(Total, na.rm = T),
                                    medianGeneration = median(Generation, na.rm = T),
                                    CountLegendary = sum(as.character(Legendary)=="True"))
    
    0 讨论(0)
提交回复
热议问题