Calculate Grouped Summary Statistics in R | group_by & summarize of dplyr Package | Multiple Columns

preview_player
Показать описание

R code of this video:

library(dplyr)

data(mtcars) # Load mtcars data
mtcars

mtcars %>% # Group by one column
group_by(cyl) %>%
summarize(mean_mpg = mean(mpg))

mtcars %>% # Multiple summary statistics
group_by(cyl) %>%
summarize(
mean_mpg = mean(mpg),
max_mpg = max(mpg))

mtcars %>% # Group by multiple columns
group_by(cyl, gear) %>%
summarize(mean_mpg = mean(mpg))

Follow me on Social Media:
Рекомендации по теме
Комментарии
Автор

It has been a while...thank you for the video. I was having some difficulty with group().

johneagle
Автор

Hii sir, i wanna learn r programming language from scratch. How can I learn?

Ragav_
Автор

hello sir, do I need to understand differential equations to understand time series or stochastic modeling?

zonerazolau-es
Автор

Hy sir
Sir I import a excel dataset in Rstudio version 4.3.2 but when I was want to see colnames, it gives me "null"...
Kindly give me some suggestion who can I solve this problem 🙏

SidraTulMuntaha-byck
Автор

I am getting error in implementation of codes.

mtcars %>% # Group by one column
+ group_by(cyl) %>%
+ summarize(mean_mpg = mean(mpg))
Error in mtcars %>% group_by(cyl) %>% summarize(mean_mpg = mean(mpg)) :
could not find function "%>%"

ashisranjanudgata
Автор

Thanks, I need to merge rows with string variables, and Sumrize doesn't work for me. Could you help me?

sasah