R Markdown

  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. Remember to load pastecs “library(pastecs)”
  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
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(pastecs)
## 
## Attaching package: 'pastecs'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
Animal_Control<-read_csv("Animal_Care_and_Control_Division_Annual_Statistics.csv")
## Rows: 22 Columns: 17
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (17): Year, Number of Employees, Number of Division Vehicles, Annual Bud...
## 
## ℹ 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.
pastecs::stat.desc(Animal_Control$Euthanized)
##      nbr.val     nbr.null       nbr.na          min          max        range 
## 2.200000e+01 0.000000e+00 0.000000e+00 8.500000e+01 2.277000e+03 2.192000e+03 
##          sum       median         mean      SE.mean CI.mean.0.95          var 
## 1.830400e+04 6.245000e+02 8.320000e+02 1.530034e+02 3.181880e+02 5.150210e+05 
##      std.dev     coef.var 
## 7.176497e+02 8.625597e-01

#This variable is measuring the number of animals that were euthanized over two decades at the Bloomington, Indiana animal shelter. This variable is going down as the years go by and the rates of adoption, Return-to-Owner, and fosting goest up.

Animal_Control<-Animal_Control %>% filter(Euthanized>100)
Animal_Control<- Animal_Control %>% drop_na(Euthanized)
hist(Animal_Control$Euthanized)

Animal_Control<-Animal_Control %>% mutate(Euthanized_Transformed=log(Euthanized))
 
hist(Animal_Control$Euthanized_Transformed)    

Animal_Control<- Animal_Control %>% mutate(Euthanized_Transformed=sqrt(Euthanized))
hist(Animal_Control$Euthanized_Transformed)