This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
#install.packages("openintro")
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.0 ✔ readr 2.1.6
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.2 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(openintro)
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
data(cchousing)
str(cchousing)
## tibble [75 × 1] (S3: tbl_df/tbl/data.frame)
## $ price: num [1:75] 506 614 755 483 588 ...
summary(cchousing)
## price
## Min. : 400.1
## 1st Qu.: 522.0
## Median : 582.1
## Mean : 611.6
## 3rd Qu.: 686.7
## Max. :1093.7
cchousing%>%
summarize(
average_price = mean(price),
median_price = median(price),
max_price = max(price),
min_price = min(price))
## # A tibble: 1 × 4
## average_price median_price max_price min_price
## <dbl> <dbl> <dbl> <dbl>
## 1 612. 582. 1094. 400.
##Cleaning
housing_clean <-cchousing %>%
filter(!is.na(price))%>%
select(price)
head(housing_clean)
## # A tibble: 6 × 1
## price
## <dbl>
## 1 506.
## 2 614.
## 3 755.
## 4 483.
## 5 588.
## 6 609.
##Scatterplot of Cost for every student
ggplot(housing_clean, aes(x = 1:75, y = price))+
geom_point(color = "black")+
labs(
title = "Community College Housing Cost",
x = "Student Number",
y = "Monthly Cost"
)