10C: Can you make a living wage as a social media influencer?
# This code will load the R packages we will use
suppressPackageStartupMessages({
library(mosaic)
library(supernova)
})
font_size = function (size) {
theme(text = element_text(size = size))}
# Adjust scientific notation
options(scipen = 999)
middle <- function(x, prop = .95) {
sorted <- sort(x)
tail_size <- (1 - prop) / 2
upper_cut <- sorted[floor(length(x) * (1 - tail_size))]
lower_cut <- sorted[ceiling(length(x) * tail_size)]
((x <= upper_cut) + (x > lower_cut)) == 2
}
# Adjust the plots to have nice sizes
options(repr.plot.width = 6, repr.plot.height = 4)
YouTubers <- read.csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vRc-xoYTbcG_kCs0oNcR0uDgXn0MWroDw9e-EqLJeFDsRtNqXZJqt7A43IvhrSyjR8uEozsKjIy9EH3/pub?gid=615413346&single=true&output=csv", header=TRUE)
head(YouTubers)
gf_histogram(~Income, data = YouTubers, color = "darkgreen", fill = "lightgreen")%>%
gf_boxplot(color="darkblue", fill ="lightblue")
#lm(Income ~ NULL, data = YouTubers)
#b0(Income ~ NULL, data = resample(YouTubers))
sdob <- do(3) * b0(Income ~ NULL, data = resample(YouTubers))
# to help us talk about "likely" samples in a sampling distribution
# try running this code
gf_histogram(~ b0, data = sdob, bins = 100, fill = ~middle(b0, .95))
# fit and save the empty model
emptymodel <- lm(Income ~ NULL, data = YouTubers)
# calculate the confidence interval
confint(emptymodel)
# Compare the sample and the sampling distributions
gf_dhistogram(~Income, data = YouTubers, color = "darkgreen", fill = "lightgreen", bins = 100) %>%
gf_dhistogram(~b0, data = sdob, color = "gray", fill = "black", bins = 100)