Calculate Variance in R (3 Examples) | Apply var, sqrt & sd Functions | Sample & Population Formula

preview_player
Показать описание
R code of this video:

x <- c(2, 7, 7, 4, 5, 1, 3) # Create example vector

var(x) # Apply var function in R

var_pop <- function(x) { # Create function for population variance
mean((x - mean(x))^2)
}

var_pop(x) # Apply population variance function

sqrt(var(x)) # Convert variance to standard deviation

sd(x) # Compare with sd function

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

hello i want to compare the variance between men and women in relation to a question from a quiz. How can i group the answers for the question to only be men or women? Thank you

ItsADrunkWorld