Exercise 8. Using EDA to explore changes
We have seen how the average can be affected by outliers. But how large can this effect get? This of course depends on the size of the outlier and the size of the dataset.
To see how outliers can affect the average of a dataset, let's write a simple function that takes the size of the outlier as input and returns the average.
This exercise is part of the course
Data Science Visualization - Module 2
Exercise instructions
Write a function called error_avg
that takes a value k
and returns the average of the vector x
after the first entry changed to k
. Show the results for k=10000
and k=-10000
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
x <- Galton$child
error_avg <- function(k){
}