Does this code demonstrate the central limit theorem? This is not a homework assignment! Au contraire, I'm a faculty teaching some methods to non-stats students.
library(tidyverse)
#Make fake data
population<-rnorm(1000000, mean=100, sd=10)
#Draw 100 samples of size 5
map(1:100, ~sample(population, size=5)) %>%
#calculate their mean
map(., mean) %>%
#unlist
unlist() %>%
#draw histogram of sample means
hist(, xlim=c(80,120))
#Repeat but with sample size 500
map(1:100, ~sample(population, size=500)) %>%
map(., mean) %>%
unlist() %>%
hist(., xlim=c(80,120))
#Repeat but with sample size 1000
map(1:100, ~sample(population, size=1000)) %>%
map(., mean) %>%
unlist() %>%
hist(., xlim=c(80,120))