App overview

TD
13 mei, 2019

Idea overview

The uploaded Shiny app is made to visually test two hypothesis

  • There is a relation between murders per 100.000 people and assaults per state
  • Cities tend to have more violence than the country side

Data preparation

The data is prepared by loading USArrests, brining the state names to a column called 'states', moving the data to a tibble and adding the columns 'urban_murders' and 'urban_assualts' by multiplying the columns 'Murder' and 'Assault' (respectively) by the column 'UrbanPop' and divide by 100.

    data(USArrests)
    df <- data.frame(USArrests)
    df <- cbind(df, states=row.names(df))
    df$states <- as.character(df$states)
    tbl_arrests <- as_tibble(df)
    tbl_arrests$urban_murders <- df$Murder / (df$UrbanPop / 100)
    tbl_arrests$urban_assaults <- df$Assault / (df$UrbanPop / 100)

Murder arrests vs assault arrests

The first plot created is a plot showing the relation between murder arrests (per 100.000 people) and assault arrests (per 100.000 people)

plot of chunk unnamed-chunk-3

From the plot it can be seen that there is a strong relation between murders and assaults per 100.000 people

Murder arrests vs assault arrests compensated by urban pop.

The second plot created is a plot showing the relation between murder arrests (per 100.000 urban residents) and assault arrests (per 100.000 urban residents)

plot of chunk unnamed-chunk-4

When compensated for urban population it seems te be more related indicating that there is a relation between percentage urban population and the amount of murders per 100.000 people (admittedly this could also be plotted directly but this was more fun)