| mean | R Documentation |
Calculates the arithmetic mean of a numeric vector.
The first argument x is a numeric vector. Setting
na.rm = TRUE will remove NA's in the vector before
calculating the mean.
mean(x, na.rm = FALSE)
min(), max(), median(), quantile()
c(1, 2, 3) %>% mean()
#> [1] 2
-----------------------------------
# Missing values
c(1, 2, NA) %>% mean()
#> [1] NA
c(1, 2, NA) %>% mean(na.rm = T)
#> [1] 1.5
-----------------------------------
library(gapminder)
# Average life expectancy of countries
# each year:
gapminder %>%
group_by(year) %>%
summarize(lifeExp_mean = mean(lifeExp))
#> A tibble: 12 x 2
#> year lifeExp_mean
<int> <dbl>
#> 1 1952 49.1
#> 2 1957 51.5
#> 3 1962 53.6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.