Commit 8dc8ab0d authored by Arndt Leininger's avatar Arndt Leininger

improved task 7 in hands-on 2

parent b3ec71cf
......@@ -21,5 +21,9 @@
# is a single spreadsheet from this file: https://files.datapress.com/london/dataset/metropolitan-police-service-recorded-crime-figures-and-associated-data/2015-12-23T15:58:16/MASTER_mps-figures.xls
# 6. The data report the fraction of citizens worried about crime in a borough
# at a given time. What's wrong about this dataset? Tidy it up.
# Hint: check the values of the variable foc.
\ No newline at end of file
# at a given time. It's in wide format, turn it into long or so-called "tidy"
# format using gather() from the package tidyr.
# 7. The data is still not ready to be analyzed.
# What's wrong about this dataset? Hint: check the values of the variable foc.
# And adjust the coding.
\ No newline at end of file
......@@ -37,10 +37,9 @@ m <- left_join(a, r, by = c('nation' = 'country', 'time'))
# is a single spreadsheet from this file: https://files.datapress.com/london/dataset/metropolitan-police-service-recorded-crime-figures-and-associated-data/2015-12-23T15:58:16/MASTER_mps-figures.xls
foc <- read.csv('data/fearofcrime_borough.csv', stringsAsFactors = F) %>% as_tibble()
# 7. The data report the fraction of citizens worried about crime in a borough
# at a given time. What's wrong about this dataset? Tidy it up.
# Hint: check the values of the variable foc.
# 6. The data report the fraction of citizens worried about crime in a borough
# at a given time. It's in wide format, turn it into long or so-called "tidy"
# format using gather() from the package tidyr.
foc
glimpse(foc)
......@@ -49,3 +48,12 @@ library(tidyr)
foc_tidy <- foc %>% gather(key = 'Borough', value = 'foc',
Barking.and.Dagenham:Westminster)
# 7. The data is still not ready to be analyzed.
# What's wrong about this dataset? Hint: check the values of the variable foc.
# And adjust the coding.
range(foc_tidy$foc)
sort(unique(foc_tidy$foc))
foc_tidy$foc[which(foc_tidy$foc > 1)] <-
foc_tidy$foc[which(foc_tidy$foc > 1)] / 100
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment