summarise_if() 计算所有数字列的平均值 msleep%>%group_by(vore)%>%summarise_if(is.numeric,mean,na.rm=TRUE) rename_if( )对列进行重命名 msleep%>%group_by(vore)%>%summarise_if(is.numeric,mean,na.rm=TRUE)%>%rename_if(is.numeric,~paste0("avg_",.)) ## vore avg_sleep_total avg_slee...
summarise_all()概括所有列 summarise_all(mtcars, mean) # 对mtcars的所有列进行均值计算 summarise_at()使用变量名称指定列进行概括 starwars %>% summarise_at(c("height", "mass"), mean, na.rm = TRUE) summarise_if()使用条件检验,满足条件的进行概括starwars %>% summarise_if(is.numeric, mean, na...
summarise_if(is.numeric, mean, na.rm =TRUE)#> # A tibble: 1 × 3#> height mass birth_year#> <dbl> <dbl> <dbl>#> 1 174. 97.3 87.6starwars %>% summarise(across(where(is.numeric), ~ mean(.x, na.rm =TRUE)))#> # A tibble: 1 × 3#> height mass birth_year#> <dbl> <...