When the dataset has an even number of values, the median is calculated as the average of the two middle values.
Here's an example code snippet:
# Create a numeric vector with even number of values
data <- c(10, 20, 30, 40)
# Calculate the median
median_value <- median(data)
# Print the median
print(median_value)
Output:
[1] 25