Using Base R

Example 2 Computing the Median

Table1 <- c(82, 77, 90, 71, 62, 68, 74, 84, 94, 88)
median(Table1)
## [1] 79.5

So, M = 79.5.

Using Mosaic

Be sure Mosaic is installed.

install.packages("mosaic")

Example 2 Computing the Median

First, we will manually enter the data in R. The Mosaic package assumes the data has column names, so we need to include the column name when building the data frame.

Table1 <- data.frame(score=c(82, 77, 90, 71, 62, 68, 74, 84, 94, 88))
head(Table1, n = 3)
##   score
## 1    82
## 2    77
## 3    90

Now, use the median(…) command with Mosaic. Recall, the syntax is

median(~variable_name,data=df_name)

library(mosaic)
median(~score,data=Table1)
## [1] 79.5

So, M = 79.5.