TD
13 mei, 2019
The uploaded Shiny app is made to visually test two hypothesis
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)
The first plot created is a plot showing the relation between murder arrests (per 100.000 people) and assault arrests (per 100.000 people)
From the plot it can be seen that there is a strong relation between murders and assaults per 100.000 people
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)
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)