How to compute quantiles in the R programming language. More details: [ Ссылка ]
R code of this video:
set.seed(15051) # Set seed for reproducibility
x <- round(runif(1000, 0, 100)) # Create uniformly distributed data
x # Print data to RStudio console
quantile(x) # Apply quantile function
x_NA <- c(x, NA) # Create example data with NA
quantile(x_NA) # Apply quantile function to NA vector
quantile(x_NA, na.rm = TRUE) # Use na.rm argument
unname(quantile(x)) # Get only the quantile values
data(iris) # Load Iris data
head(iris) # Head of Iris data
# The dplyr package is not needed. This was a little mistake I made at 04:00 in the video.
# install.packages("dplyr") # Install dplyr package
# library("dplyr") # Load dplyr package
do.call("rbind",
tapply(iris$Sepal.Length, # Specify numeric column
iris$Species, # Specify group variable
quantile))
quantile(x, probs = 0.5) # Median
quantile(x, probs = seq(0, 1, 1/3)) # Tertiles
quantile(x, probs = seq(0, 1, 1/4)) # Quartiles
quantile(x, probs = seq(0, 1, 1/5)) # Quintiles
quantile(x, probs = seq(0, 1, 1/6)) # Sextiles
quantile(x, probs = seq(0, 1, 1/7)) # Septiles
quantile(x, probs = seq(0, 1, 1/8)) # Octiles
quantile(x, probs = seq(0, 1, 1/10)) # Deciles
quantile(x, probs = seq(0, 1, 1/12)) # Duo-deciles or dodeciles
quantile(x, probs = seq(0, 1, 1/16)) # Hexadeciles
quantile(x, probs = seq(0, 1, 1/20)) # Ventiles, vigintiles, or demi-deciles
quantile(x, probs = seq(0, 1, 1/100)) # Percentiles
quantile(x, probs = seq(0, 1, 1/1000)) # Permilles or milliles
y <- x + rnorm(1000, 0, 30) # Create y-data
qqplot(x, y) # Quantile-Quantile plot of x & y
Follow me on Social Media:
Facebook – Statistics Globe Page: [ Ссылка ]
Facebook – Group for Discussions & Questions: [ Ссылка ]
LinkedIn – Statistics Globe Page: [ Ссылка ]
LinkedIn – Group for Discussions & Questions: [ Ссылка ]
Twitter: [ Ссылка ]
Music by bensound.com
Ещё видео!