library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.4.3
## Warning: package 'ggplot2' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## âś” dplyr     1.1.4     âś” readr     2.1.5
## âś” forcats   1.0.0     âś” stringr   1.5.1
## âś” ggplot2   3.5.1     âś” tibble    3.2.1
## âś” lubridate 1.9.4     âś” tidyr     1.3.1
## âś” purrr     1.0.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(pastecs)
## Warning: package 'pastecs' was built under R version 4.4.3
## 
## Attaching package: 'pastecs'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
  1. From the data you have chosen, select a variable that you are interested in
pavements<-read.csv("pavements_3192083553624189959.csv")
  1. Use pastecs::stat.desc to describe the variable. Include a few sentences about what the variable is and what it’s measuring.
stat.desc(pavements$PCI)
##      nbr.val     nbr.null       nbr.na          min          max        range 
## 9.797200e+04 1.351000e+03 0.000000e+00 0.000000e+00 9.999000e+01 9.999000e+01 
##          sum       median         mean      SE.mean CI.mean.0.95          var 
## 7.725931e+06 8.700000e+01 7.885856e+01 6.046350e-02 1.185077e-01 3.581694e+02 
##      std.dev     coef.var 
## 1.892536e+01 2.399912e-01

Variable description: Pavement Condition Index (PCI) is the rating assigned to the roadway segment

  1. Remove NA’s if needed using dplyr:filter (or anything similar)
pavement<-pavements%>%select(PCI)%>%na.omit(.)
pavement_removed<-pavement%>%filter(PCI>0)
  1. Provide a histogram of the variable (as shown in this lesson)
hist(pavement$PCI,breaks=10,probability = T)
lines(density(pavement$PCI),col='red',lwd=2)

  1. transform the variable using the log transformation or square root transformation (whatever is more appropriate) using dplyr::mutate or something similar
pavement_log<-pavement_removed %>% mutate(LOG_PCI=log(PCI)) %>% select(PCI,LOG_PCI)
  1. provide a histogram of the transformed variable
hist(pavement_log$LOG_PCI,breaks=10,probability = T)
lines(density(pavement_log$LOG_PCI),col='red',lwd=2)

pavement_sqrt<-pavement_removed %>% mutate(PCI_SQRT=sqrt(PCI))
hist(pavement_sqrt$PCI_SQRT,breaks=10,probability = T)
lines(density(pavement_sqrt$PCI_SQRT),col='red',lwd=2)

  1. submit via rpubs on CANVAS

This log and sqrt did not make my data look more normal. Should I mutate my data to have less obersations? Wouldn’t this be incorrect since its destorying the data to make it fit what I want to see?