library(tidyverse)
## -- Attaching packages ------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2 v purrr 0.3.4
## v tibble 3.0.3 v dplyr 1.0.2
## v tidyr 1.1.2 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.5.0
## -- Conflicts ---------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(openintro)
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
Question 1
cholesterol <- c(373, 327, 274, 292, 274, 280, 301, 315, 285, 299, 320, 249, 313, 222, 254, 289, 300, 295, 292, 267)
mean(cholesterol)
## [1] 291.05
median(cholesterol)
## [1] 292
sd(cholesterol)
## [1] 31.94811
q1 <- quantile(cholesterol, prob=.25)
q3 <- quantile(cholesterol, prob = .75)
IQR <- q3-q1
id <- c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,15,16, 17, 18, 19, 20)
df <- data.frame(id, cholesterol)
ggplot(data= df, aes(cholesterol)) +
geom_boxplot()

ggplot(data= df, aes(cholesterol)) +
geom_histogram(binwidth = 25)

Question 2
low_light <- c(264, 200, 225, 268, 215, 241, 232, 256, 229, 288, 253, 288, 230)
mod_light <- c(314, 320, 310, 340, 299, 268, 345, 271, 285, 309, 337, 282, 273)
soybean <- data.frame(low_light, mod_light)
ggplot(data = soybean, aes(x = low_light, y= mod_light)) +
geom_point()

ggplot(soybean, aes(x=low_light, y= mod_light)) +
geom_point()+
geom_smooth(method=lm, se=FALSE)
## `geom_smooth()` using formula 'y ~ x'
