library(yarrr)
## Loading required package: jpeg
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## 
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## 
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# Question 1 A
x <- rnorm(100, mean = 100, sd = 10)
y <- x + rnorm(100, mean = 20, sd = 20)
# Question 1 B
hist(x = x,
     main = "Histogram of x",
     xlab = "This is the x-label",
     xlim  = c(50, 200)
)

# Question 1 C
hist(x = y,
     main = "Histogram of y",
     xlab = "This is the x-label",
     xlim  = c(50, 200)
)

# Question 1 D
plot(x = x,
     y = y,
     xlab = "This is the x-label",
     ylab = "This is the y-label",
     main = "This is the title",
     pch = 16,
     col = gray(level = .1, alpha = .1)
)

# Question 1 E
abline(v = mean(x))
abline(h = mean(y)) 

# Question 2
colors()[1:10]
##  [1] "white"         "aliceblue"     "antiquewhite"  "antiquewhite1"
##  [5] "antiquewhite2" "antiquewhite3" "antiquewhite4" "aquamarine"   
##  [9] "aquamarine1"   "aquamarine2"
sample(x = 1:100, 
       size = 10)
##  [1] 89 93 24 99 53 76 16  9 35 13
samp.numbers <- sample(1:657, size = 10)
colors.to.use <- colors()[samp.numbers]

plot(1:10, 
     col = colors.to.use,
     pch = 16,
     cex = 2,
     xlim = c(0, 11),
     ylim = c(0, 11)
)

text(1:10, 
     1:10, 
     colors()[samp.numbers],
     pos = 3
)

# Question 3
names(pirates)
##  [1] "id"              "sex"             "headband"       
##  [4] "age"             "college"         "tattoos"        
##  [7] "tchests"         "parrots"         "favorite.pirate"
## [10] "sword.type"      "sword.time"      "eyepatch"       
## [13] "beard.length"    "fav.pixar"
boxplot(sword.time~sword.type,
        data = pirates,
        xlab = "sword.type",
        ylab = "sword.time",
        main = "Sword swinging time by sword type")