Headshot Photo

Introduction

Hello! I’m majoring in M.S in Business Analytics, my background includes military, retail, construction and data analytical experience. I grew up everywhere, I was part of a military family. But for most of my adult life I have considered Cincinnati my home. My favorite things to do is code, play video games and workout.

Academic Background

B.S. in Business Analytics B.A. in Business Economics M.S. in Business Analytics (Working On)

Professional Background

Currently I am an Data Analyst at altafiber and an Information Technology Advisor for the United States Army.

Experience with R

I have been programming in R for nearly four years now. I started using R during my undergraduate course work and built upon this knowledge from 2019 till now I have performed a diverse set of analytic functions with R through out my schooling and I wouldn’t say I know all there is to know about R but I am proficient in utilizing R effectively. I do look forward in learning more about R and other language throughout my graduate program.

Experience with other analytic software

As stated above throughout my schooling I have used R but also have learned a bit about SQL as well as Python.

library(here)
## Warning: package 'here' was built under R version 4.1.3
## here() starts at C:/Users/micha/OneDrive/Desktop/Data Wrangler/Lab Quiz 2
library(readr)
## Warning: package 'readr' was built under R version 4.1.3
  1. Import the blood_transfusion.csv file (provided via Canvas).
data_path <- here("blood_transfusion.csv")
transfusion <- read_csv(data_path)
## Rows: 748 Columns: 5
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): Class
## dbl (4): Recency, Frequency, Monetary, Time
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.

•What are the dimensions of this data (number of rows and columns)?

dim(transfusion)
## [1] 748   5

•What are the data types of each column?

colnames(transfusion)
## [1] "Recency"   "Frequency" "Monetary"  "Time"      "Class"

•Are there any missing values?

sapply(transfusion, function(x) sum(is.na(x)))
##   Recency Frequency  Monetary      Time     Class 
##         0         0         0         0         0

•Check out the first 10 rows? What are the Class values for the first 10 observations?

head(transfusion,10)
## # A tibble: 10 x 5
##    Recency Frequency Monetary  Time Class      
##      <dbl>     <dbl>    <dbl> <dbl> <chr>      
##  1       2        50    12500    98 donated    
##  2       0        13     3250    28 donated    
##  3       1        16     4000    35 donated    
##  4       2        20     5000    45 donated    
##  5       1        24     6000    77 not donated
##  6       4         4     1000     4 not donated
##  7       2         7     1750    14 donated    
##  8       1        12     3000    35 not donated
##  9       2         9     2250    22 donated    
## 10       5        46    11500    98 donated

•Check out the last 10 rows? What are the Class values for the last 10 observations?

tail(transfusion,10)
## # A tibble: 10 x 5
##    Recency Frequency Monetary  Time Class      
##      <dbl>     <dbl>    <dbl> <dbl> <chr>      
##  1      23         1      250    23 not donated
##  2      23         4     1000    52 not donated
##  3      23         1      250    23 not donated
##  4      23         7     1750    88 not donated
##  5      16         3      750    86 not donated
##  6      23         2      500    38 not donated
##  7      21         2      500    52 not donated
##  8      23         3      750    62 not donated
##  9      39         1      250    39 not donated
## 10      72         1      250    72 not donated

•Index for the 100th row and just the Monetary column. What is the value?

transfusion$Monetary[100]
## [1] 1750

•Index for just the Monetary column. What is the mean of this vector?

mean(transfusion$Monetary)
## [1] 1378.676

•Subset this data frame for all observations where Monetary is greater than the mean value. How many rows are in the resulting data frame?

sum(transfusion$Monetary > mean(transfusion$Monetary))
## [1] 267
  1. Go to this University of Dayton webpage http://academic.udayton.edu/kissock/http/Weather/ citylistUS.htm, scroll down to Ohio and import the Cincinnati (OHCINCIN.txt) file.
url <- 
'http://academic.udayton.edu/kissock/http/Weather/gsod95-current/OHCINCIN.txt'
weather <- read_table(url, col_names = c("Month", "Date", "Year", "Temp"))
## 
## -- Column specification --------------------------------------------------------
## cols(
##   Month = col_double(),
##   Date = col_double(),
##   Year = col_double(),
##   Temp = col_double()
## )
## Warning: 3 parsing failures.
##  row col  expected    actual                                                                           file
## 4623  -- 4 columns 5 columns 'http://academic.udayton.edu/kissock/http/Weather/gsod95-current/OHCINCIN.txt'
## 5016  -- 4 columns 5 columns 'http://academic.udayton.edu/kissock/http/Weather/gsod95-current/OHCINCIN.txt'
## 5213  -- 4 columns 5 columns 'http://academic.udayton.edu/kissock/http/Weather/gsod95-current/OHCINCIN.txt'
head(weather)
## # A tibble: 6 x 4
##   Month  Date  Year  Temp
##   <dbl> <dbl> <dbl> <dbl>
## 1     1     1  1995  41.1
## 2     1     2  1995  22.2
## 3     1     3  1995  22.8
## 4     1     4  1995  14.9
## 5     1     5  1995   9.5
## 6     1     6  1995  23.8

•What are the dimensions of this data (number of rows and columns)?

dim(weather)
## [1] 9265    4

•What do you think these columns represent?

These columns represent the average daily temperature of Cincinnati from 1st January,1995 to 13th May,2020.

•Are there any missing values in this data?

sum(is.na(weather))
## [1] 0

•Index for the 365th row. What is the date of this observation and what was the average temperature?

weather[365,]
## # A tibble: 1 x 4
##   Month  Date  Year  Temp
##   <dbl> <dbl> <dbl> <dbl>
## 1    12    31  1995  39.3
weather[365,c("Date","Temp")]
## # A tibble: 1 x 2
##    Date  Temp
##   <dbl> <dbl>
## 1    31  39.3

•Subset for all observations that happened during January of 2000. What was the median average temp for this month?

weather_sub <- weather[ which( weather$Month == 1 & weather$Year == 2000) , ]
print(paste("The median temperature for January 2020 was:",median(weather_sub$Temp)))
## [1] "The median temperature for January 2020 was: 27.1"

•Which date was the highest average temp recorded (hint: which.max)?

weather[which.max(weather$Temp),]
## # A tibble: 1 x 4
##   Month  Date  Year  Temp
##   <dbl> <dbl> <dbl> <dbl>
## 1     7     7  2012  89.2

•Which date was the cold average temp recorded? Does this temp make sense? Are there more than just one date that has this temperature value recorded? If so, how many?

position2 <- which.min(weather$Temp)
print(paste("The lowest temperature was:",weather[position2,4], " and was recorded on:",weather[position2,1],"/",weather[position2,2],"/",weather[position2,3]))
## [1] "The lowest temperature was: -99  and was recorded on: 12 / 24 / 1998"
# The -99 temperature does not make any sense. The dates having -99 temperature is an error. There are more than one date in # which the temperature recorded was -99.
print(paste("The total number of dates on which the average temperature was recorded as -99 are:",sum(weather$Temp == -99)))
## [1] "The total number of dates on which the average temperature was recorded as -99 are: 14"

•Compute the mean of the average temp column. Now re-code all -99s to NA and recompute the mean.

mean(weather$Temp)
## [1] 54.39876
weather$Temp <- ifelse(weather$Temp <= -99, NA, weather$Temp)
mean(weather$Temp, na.rm = TRUE)
## [1] 54.6309
  1. Import the PDI__Police_Data_Initiative__Crime_Incidents.csv data (provided via Canvas). Data is taken from the City of Cincinnati Open Data Portal website 4, which you may need to read to place context in your answers.
data_path_police <- here("PDI__Police_Data_Initiative__Crime_Incidents.csv")
police <- read_csv(data_path_police)
## Rows: 15155 Columns: 40
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (34): INSTANCEID, INCIDENT_NO, DATE_REPORTED, DATE_FROM, DATE_TO, CLSD, ...
## dbl  (6): UCR, LONGITUDE_X, LATITUDE_X, TOTALNUMBERVICTIMS, TOTALSUSPECTS, ZIP
## 
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.

•What are the dimensions of this data (number of rows and columns)?

dim(police)
## [1] 15155    40

•What do you think these columns represent?

•Are there any missing values in this data? If so, how many missing values are in each column? Which column has the most missing values?

sum(is.na(police))
## [1] 95592
colSums(is.na(police))
##                     INSTANCEID                    INCIDENT_NO 
##                              0                              0 
##                  DATE_REPORTED                      DATE_FROM 
##                              0                              2 
##                        DATE_TO                           CLSD 
##                              9                            545 
##                            UCR                            DST 
##                             10                              0 
##                           BEAT                        OFFENSE 
##                             28                             10 
##                       LOCATION                     THEFT_CODE 
##                              2                          10167 
##                          FLOOR                           SIDE 
##                          14127                          14120 
##                        OPENING                      HATE_BIAS 
##                          14508                              0 
##                      DAYOFWEEK                       RPT_AREA 
##                            423                            239 
##               CPD_NEIGHBORHOOD                        WEAPONS 
##                            249                              5 
##              DATE_OF_CLEARANCE                      HOUR_FROM 
##                           2613                              2 
##                        HOUR_TO                      ADDRESS_X 
##                              9                            148 
##                    LONGITUDE_X                     LATITUDE_X 
##                           1714                           1714 
##                     VICTIM_AGE                    VICTIM_RACE 
##                              0                           2192 
##               VICTIM_ETHNICITY                  VICTIM_GENDER 
##                           2192                           2192 
##                    SUSPECT_AGE                   SUSPECT_RACE 
##                              0                           7082 
##              SUSPECT_ETHNICITY                 SUSPECT_GENDER 
##                           7082                           7082 
##             TOTALNUMBERVICTIMS                  TOTALSUSPECTS 
##                             33                           7082 
##                      UCR_GROUP                            ZIP 
##                             10                              1 
## COMMUNITY_COUNCIL_NEIGHBORHOOD               SNA_NEIGHBORHOOD 
##                              0                              0
#Column with most missing values
print(paste("The column with the most missing values is:",colnames(police)[colSums(is.na(police)) == max(sapply(police, function(x) sum(is.na(x))))]," with total number of", max(sapply(police, function(x) sum(is.na(x)))),"missing values "))
## [1] "The column with the most missing values is: OPENING  with total number of 14508 missing values "

•Using the DATE_REPORTED column, what is the range of dates included in this data?

range(police$DATE_REPORTED)
## [1] "01/01/2022 01:08:00 AM" "06/26/2022 12:50:00 AM"

•Using table(), what is the most common age range for known SUSPECT_AGEs?

table(police$SUSPECT_AGE)
## 
##    18-25    26-30    31-40    41-50    51-60    61-70  OVER 70 UNDER 18 
##     1778     1126     1525      659      298      121       16      629 
##  UNKNOWN 
##     9003

•Use table() to get the number of incidents per zip code. Sort this table for those zip codes with the most activity to the least activity. Which zip code has the most incidents? Do you see any peculiar data quality issues with any of these zip code values?

table(police$ZIP)
## 
##  4523  5239 42502 45202 45203 45204 45205 45206 45207 45208 45209 45211 45212 
##     2     1     3  2049   226   348  1110   616   245   359   380  1094    61 
## 45213 45214 45215 45216 45217 45219 45220 45221 45223 45224 45225 45226 45227 
##   190   774    47   302   100   863   477    90   653   429   811   112   286 
## 45228 45229 45230 45231 45232 45233 45236 45237 45238 45239 45244 45248 
##     5   913   214     7   477    77     3   699   956   169     3     3

•Using the DAYOFWEEK column, which day do most incidents occur on? What is the proportion of incidents that fall on this day?

table(police$DAYOFWEEK) / length(police$DAYOFWEEK)
## 
##    FRIDAY    MONDAY  SATURDAY    SUNDAY  THURSDAY   TUESDAY WEDNESDAY 
## 0.1331574 0.1398218 0.1499175 0.1408116 0.1324975 0.1392940 0.1365886

•Looking at the information this data set provides, what are some insights you’d be interested in assessing? Analyze three different columns that could start to provide you with these insights. Are there missing values in these columns? What are some summary statistics you can compute for these columns? Are there any outliers or aberrant values in these columns? How do you know? Would you remove or recode them?

Each row likely represents a police report that was filed. Each column is an attribute of the police report. There are 95592 missing values in the data frame. The Floor column has the most missing values. The dates range from 1/1/2022 to 6/9/2022. The most common age range is 18-25. The zip code that has the most incidents is 45202. Some of the zip codes appear to have not enough digits, and are typos. The most common day is Saturday, with 14.99% of incidents.