library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.2.1     ✔ readr     2.2.0
## ✔ forcats   1.0.1     ✔ stringr   1.6.0
## ✔ ggplot2   4.0.3     ✔ tibble    3.3.1
## ✔ lubridate 1.9.5     ✔ tidyr     1.3.2
## ✔ purrr     1.2.2     
## ── 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(readxl)
library(pastecs)
## 
## Attaching package: 'pastecs'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
air_quality <-read_csv("air_quality.csv")
## Rows: 527132 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (3): district_id, air_quality_category, sensor_status
## dbl  (7): pm25, pm10, no2, o3, co, synthetic_aqi, pollution_alert_flag
## dttm (1): timestamp
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# Question 1: Select Variable
# air_quality$o3 #o3 "Ozone" variable

#Question 2: use  pastecs::stat.desc 
stat.desc(air_quality$o3)
##      nbr.val     nbr.null       nbr.na          min          max        range 
## 5.216910e+05 1.133600e+04 5.441000e+03 0.000000e+00 1.094414e+02 1.094414e+02 
##          sum       median         mean      SE.mean CI.mean.0.95          var 
## 1.761682e+07 3.220780e+01 3.376870e+01 2.705326e-02 5.302353e-02 3.818146e+02 
##      std.dev     coef.var 
## 1.954008e+01 5.786447e-01
#The mean for O3 is 3.376870e+01 and the median is 3.220780e+01. The mean and median are fairly close together which implies that there are not many outliers. 

#Question 3: Remove NA's if needed using dplyr:filter (or anything similar)

air_quality_clean <- air_quality %>%
    filter(!is.na(o3))

#Question 4: Provide a hystogram of the varaiable 
hist(air_quality_clean$o3)

#Question 5: transform the variable using the log transformation or square root transformation (whatever is more appropriate) using dplyr::mutate or something similar

air_quality_clean_log <- air_quality_clean %>%
  mutate(log(o3))

#Question 6:  provide a histogram of the transformed variable

hist(air_quality_clean_log$`log(o3)`)

  1. From the data you have chosen, select a variable that you are interested in
  2. Use pastecs::stat.desc to describe the variable. Include a few sentences about what the variable is and what it’s measuring.
  3. Remove NA’s if needed using dplyr:filter (or anything similar)
  4. Provide a histogram of the variable (as shown in this lesson)
  5. transform the variable using the log transformation or square root transformation (whatever is more appropriate) using dplyr::mutate or something similar
  6. provide a histogram of the transformed variable
  7. submit via rpubs on CANVAS