Finding the median of a dataset becomes increasingly time-consuming as the size of your dataset increases — imagine finding the median of an unsorted dataset with 10,000 observations.

The R `median()`

function can do the work of sorting, then finding the median for you. In the example below, we use `median()`

to calculate the median of a dataset with ten values:

example_data = c(24, 16, 30, 10, 12, 28, 38, 2, 4, 36, 42) example_median = median(example_data) print(example_median)

The code above prints the median of the dataset, `24`

. The mean of this dataset is `22`

. It’s worth noting these two values are close to one another, but not equal.

### Instructions

**1.**

Use R to find the median of the `author_ages`

array. Save the result to `median_age`

.

Does the median age of the authors surprise you? If so, how? Is it older, or younger than you expected?

# Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.