Calculate Mean of Data Frame Column in R (6 Examples) | mean, summarise of dplyr, colMeans & na.rm
Автор: Statistics Globe
Загружено: 2021-03-01
Просмотров: 21504
How to compute the average of data frame variables in the R programming language. More details: https://statisticsglobe.com/mean-of-d...
R code of this video:
data <- data.frame(x1 = 1:5, # Create example data
x2 = 9:5,
x3 = 5)
mean(data$x2) # Apply $-operator
mean(data[["x2"]]) # Apply square brackets
mean(data[ , 2]) # Specify index position
install.packages("dplyr") # Install dplyr package
library("dplyr") # Load dplyr
summarise(data, my_mean = mean(x2)) # Apply summarise function
colMeans(data) # Apply colMeans function
data_NA <- data # Create example data with NA
data_NA$x2[c(1, 3)] <- NA
mean(data_NA$x2, na.rm = TRUE) # Specify na.rm argument
Follow me on Social Media:
Facebook: / statisticsglobecom
Patreon: / statisticsglobe
Pinterest: https://www.pinterest.de/JoachimSchork
Reddit: / joachimschork
Twitter: / joachimschork
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: