Instructions to Students

This assignment is designed to simulate a scenario where you are taking over someone’s existing work, and continuing with it to draw some further insights.

This is a real world dataset taken from the Crime Statistics Agency Victoria. https://www.crimestatistics.vic.gov.au/download-data, specifically the data called “Data tables - Spotlight: Burglary/Break and Enter Offences Recorded in Victoria visualisation - year ending December 2018 (XLSX, 4.4 MB)”. The raw data is used for this assignment, with no changes made.

You are writing a quick summary of the data, following along from guidance from Amelia, and some of the questions your manager has. This is not a formal report, but rather something you are giving to your manager that describes the data, and some interesting insights. We have written example text for the first section on Monash, and would like you to explore another area. Our example writings are a good example of how to get full marks.

Your “colleague”, Amelia (in the text treatment below) has written some helpful hints throughout the assignment to help guide you.

Questions that are work marks are indicated with ** at the start and end of the question, as well as a number of marks in parenthesis.

Marking + Grades

This assignment will be worth 4% of your total grade, and will be marked out of 16 marks total.

  • 3 Marks for grammar and clarity. You must write in complete sentences and do a spell check.
  • 3 Marks for overall presentation of the data visualisations
  • 10 marks for the questions

  • Your marks will then be weighted according to peer evaluation.

  • Sections that contain marks are indicated with **, and will have the number of marks indicated in parentheses. For example:

# `**` What are the types of item divisions? How many are there? (0.5 Mark) `**`

A Note on skills

As of week 1, you have seen some of the code used here, but I do not expect you to know immediately what the code below does. This is a challenge for you! We will be covering skills on data summary and data visualisation in the next two weeks, but this assignment is designed to simulate a real life work situation - this means that there are some things where you need to “learn on the job”. But the vast majority of the assignment will cover things that you will have seen in class, or the readings.

Remember, you can look up the help file for functions by typing ?function_name. For example, ?mean. Feel free to google questions you have about how to do other kinds of plots, and post on the ED if you have any questions about the assignment.

How to complete this assignment.

To complete the assignment you will need to fill in the blanks for function names, arguments, or other names. These sections are marked with *** or ___. At a minimum, your assignment should be able to be “knitted” using the knit button for your Rmarkdown document.

If you want to look at what the assignment looks like in progress, but you do not have valid R code in all the R code chunks, remember that you can set the chunk options to eval = FALSE. If you do this, please remember to ensure that you remove this chunk option or set it to eval = TRUE when you submit the assignment, to ensure all your R code runs.

You will be completing this assignment in your assigned groups. A reminder regarding our recommendations for completing group assignments:

  • Each member of the group completes the entire assignment, as best they can.
  • Group members compare answers and combine it into one document for the final submission.

Your assignments will be peer reviewed, and results checked for reproducibility. This means:

  • 25% of the assignment grade will come from peer evaluation.
  • Peer evaluation is an important learning tool.

Each student will be randomly assigned another team’s submission to provide feedback on three things:

  1. Could you reproduce the analysis?
  2. Did you learn something new from the other team’s approach?
  3. What would you suggest to improve their work?

Due Date

This assignment is due in by close of business (5pm) on Friday 16th August. You will submit the assignment via ED. Please change the file name to include your teams name. For example, if you are team dplyr, your assignment file name could read: “assignment-1-2019-s2-team-dplyr.Rmd”

Treatment

You work as a data scientist in the well named company, “The Security Company”, that sells security products: alarms, surveillance cameras, locks, screen doors, big doors, and so on.

It’s your second day at the company, and you’re taken to your desk. Your boss says to you:

Amelia has managed to find this treasure trove of data - get this: crime statistics on breaking and entering around Victoria for the past years! Unfortunately, Amelia just left on holiday to New Zealand. They discovered this dataset the afternoon before they left on holiday, and got started on doing some data analysis.

We’ve got a meeting coming up soon where we need to discuss some new directions for the company, and we want you to tell us about this dataset and what we can do with it. We want to focus on Monash, since we have a few big customers in that area, and then we want you to help us compare that whatever area has the highest burglary.

You’re in with the new hires of data scientists here. We’d like you to take a look at the data and tell me what the spreadsheet tells us. I’ve written some questions on the report for you to answer, and there are also some questions from Amelia I would like you to look at as well.

Most Importantly, can you get this to me by COB Friday 16th August (COB = Close of Business at 5pm).

I’ve given this dataset to some of the other new hire data scientists as well, you’ll all be working as a team on this dataset. I’d like you to all try and work on the questions separately, and then combine your answers together to provide the best results.

From here, you are handed a USB stick. You load this into your computer, and you see a folder called “vic-crime”. In it is a folder called “data-raw”, and an Rmarkdown file. It contains the start of a data analysis. Your job is to explore the data and answer the questions in the document.

Note that the text that is written was originally written by Amelia, and you need to make sure that their name is kept up top, and to pay attention to what they have to say in the document! # Data read in.

Amelia: First, let’s read in the data using the function read_excel() from the readxl package, and clean up the names, using the rename function from dplyr.

## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Amelia: Let’s print the data and look at the first few rows.

## # A tibble: 43,830 x 6
##     year local_gov_area offence_subgroup item_division item_subdivision
##    <dbl> <chr>          <chr>            <chr>         <chr>           
##  1  2009 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  2  2016 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  3  2011 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  4  2015 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  5  2016 Casey          B322 Non-reside~ Car Accessor~ Car Accessories 
##  6  2013 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  7  2012 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  8  2018 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
##  9  2010 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
## 10  2014 Casey          B321 Residentia~ Car Accessor~ Car Accessories 
## # ... with 43,820 more rows, and 1 more variable: n_property_items <dbl>

Amelia: And what are the names of the columns in the dataset?

## [1] "year"             "local_gov_area"   "offence_subgroup"
## [4] "item_division"    "item_subdivision" "n_property_items"

Amelia: How many years of data are there?

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2009    2011    2014    2014    2016    2018

Amelia: We have data that goes from 2009 until 2018, that’s nine years of data!

How many Local Government Areas (LGAs) are there? And what are the LGAs called?

## [1] 80
##  [1] "Casey"                "Whittlesea"           "Greater Geelong"     
##  [4] "Hume"                 "Wyndham"              "Greater Dandenong"   
##  [7] "Brimbank"             "Melton"               "Glen Eira"           
## [10] "Frankston"            "Ballarat"             "Mornington Peninsula"
## [13] "Moreland"             "Greater Bendigo"      "Latrobe"             
## [16] "Yarra Ranges"         "Darebin"              "Knox"                
## [19] "Maroondah"            "Banyule"              "Mildura"             
## [22] "Moonee Valley"        "Moorabool"            "Maribyrnong"         
## [25] "Cardinia"             "Hobsons Bay"          "Whitehorse"          
## [28] "Kingston"             "Surf Coast"           "Greater Shepparton"  
## [31] "Boroondara"           "Bayside"              "Golden Plains"       
## [34] "Port Phillip"         "Wellington"           "Melbourne"           
## [37] "Stonnington"          "Mitchell"             "Campaspe"            
## [40] "Yarra"                "Macedon Ranges"       "East Gippsland"      
## [43] "Baw Baw"              "Manningham"           "Bass Coast"          
## [46] "Wodonga"              "Buloke"               "Moyne"               
## [49] "Hepburn"              "Central Goldfields"   "Wangaratta"          
## [52] "Colac-Otway"          "Glenelg"              "Nillumbik"           
## [55] "Ararat"               "Corangamite"          "Mount Alexander"     
## [58] "Swan Hill"            "Warrnambool"          "Moira"               
## [61] "South Gippsland"      "Loddon"               "Indigo"              
## [64] "Murrindindi"          "Strathbogie"          "Horsham"             
## [67] "Yarriambiack"         "Southern Grampians"   "Benalla"             
## [70] "Gannawarra"           "Northern Grampians"   "Pyrenees"            
## [73] "Towong"               "Alpine"               "Mansfield"           
## [76] "Hindmarsh"            "West Wimmera"         "Queenscliffe"        
## [79] "Monash"               "Victoria"

Amelia: That’s a lot of areas - about 80!

What are the types of offence subgroups? How many are there?

## [1] "B321 Residential non-aggravated burglary"    
## [2] "B322 Non-residential non-aggravated burglary"
## [3] "B329 Unknown non-aggravated burglary"        
## [4] "B311 Residential aggravated burglary"        
## [5] "B312 Non-residential aggravated burglary"    
## [6] "B319 Unknown aggravated burglary"
## [1] 6

Amelia: Remember that you can learn more about what these functions do by typing ?unique or ?n_distinct into the console.

** What are the types of item divisions? How many are there? (0.5 Mark)**

##  [1] "Car Accessories"       "Cash/Document"        
##  [3] "Cigarettes/Liquor"     "Clothing"             
##  [5] "Electrical Appliances" "Domestic Pets"        
##  [7] "Explosives"            "Firearms/Ammunition"  
##  [9] "Food"                  "Furniture"            
## [11] "Garden Items"          "Household Items"      
## [13] "Jewellery"             "Other"                
## [15] "Livestock"             "Marine Property"      
## [17] "Personal Property"     "Photographic Equip"   
## [19] "Police Property"       "Power Tools"          
## [21] "Sporting Goods"        "Timber/Build Mat"     
## [23] "Tools"                 "Tv/Vcr"               
## [25] "Weapons"
## [1] 25

** What are the types of item subdivisions? (0.5 Mark) **

##  [1] "Car Accessories"             "Cash/Document"              
##  [3] "Cigarettes/Liquor"           "Clothing"                   
##  [5] "Computer"                    "Domestic Pets"              
##  [7] "Explosives"                  "Firearms/Ammunition"        
##  [9] "Food"                        "Furniture"                  
## [11] "Garden Items"                "Household Items"            
## [13] "Jewellery"                   "Key"                        
## [15] "Laptop"                      "Livestock"                  
## [17] "Marine Property"             "Mobile Phone"               
## [19] "Other Electrical Appliances" "Other Property Items"       
## [21] "Personal Property"           "Photographic Equip"         
## [23] "Police Property"             "Power Tools"                
## [25] "Speaker"                     "Sporting Goods"             
## [27] "Tablet Computer"             "Timber/Build Mat"           
## [29] "Tools"                       "Tv/Vcr"                     
## [31] "Video Game Unit"             "Weapons"
## [1] 32

** What is the summary of the number of property items? (0.5 Mark) **

##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
##     1.00     2.00     7.00    74.15    29.00 45027.00

For all burglary crimes, the minimum number of items stolen is 1. The first quartile range falls at 2 meaning 25% cases have 2 or less items stolen in an event. The median is 7.00 meaning 50% of cases fall under 7 items stolen and 50% are more than 7. The mean is the average of items stolen. The 3rd quartile of 29 means 25% of burglary stole more than 29 items in their crime. The max value is the maximum amount of items stolen in one burglary which is 45027.

** Can you tell me what each row represents, and what each of the columns measure? (1 Mark) **

Amelia: We need to describe what each row of the data represents, and take our best guess at what we think each column measures. It might be worthwhile looking through the excel sheet in the data folder, or on the website where the data was extracted.

Each row represents one observation of a recorded case where as the columns each represent a variable of that case such as year, offence subgroup, local government area.

Is there a yearly trend in the total number of items stolen per year?

Amelia: Let’s group by year and then sum up the number of property items. Then we can take this information and use ggplot to plot the year on the x axis, and n_items on the y axis, and number of items as a column with geom_col().

Amelia: I try and write three sentences complete about what I learn in a graphic. You should start with a quick summary of what the graphic shows you. Then, describe what is on the x axis, the y axis, and any other colours used to separate the data. You then need to describe what you learn. So, I would say:

“A summary of the number of items stolen from burglaries for each year from 2009 until 2018. On the x axis is each year, and the y axis is the number of items stolen. We learn that the number of items stolen stays around 300,000 (3e+05 means the number 3 with 5 zeros after it), but from 201, the number of items stolen has decreased each year.”

Look at burglary around Monash and tell me about it?

The graph represents a summary of the number of items stolen from burglaries for each year from 2009 to 2018. The x-axis represents the year, whereas the y-axis represents the number of items stolen. We can see from the figure that there have been slight fluctuations in the number of items stolen throughout the year. For example, in 2009, there were approximately 80 items stolen in the Monash area, which drastically decreased to just above, and below 60 items in 2010 and 2011, respectively. Throughout the years until 2018, the number of items stolen around Monash have varied and averaged at approximately 60 to 80 items per year. Amelia: Let’s filter the data down to the ‘Monash’ LGAs.

Is crime in Monash increasing?

Amelia: Let’s count the number of crimes per year.

Amelia: This plot shows the number of burglary crimes per year across Victoria. The x axis shows the year, and the y axis shows the number of crimes scored for that year. There appears to be a slight upwards trend, but it looks variable for each year.

What are the most common offences in Monash across all years?

Amelia: We count the number of observations in each offence_subgroup to tell us which are the most common.

## # A tibble: 6 x 2
##   offence_subgroup                                 n
##   <chr>                                        <int>
## 1 B311 Residential aggravated burglary           117
## 2 B312 Non-residential aggravated burglary        10
## 3 B319 Unknown aggravated burglary                 6
## 4 B321 Residential non-aggravated burglary       273
## 5 B322 Non-residential non-aggravated burglary   248
## 6 B329 Unknown non-aggravated burglary            35

Amelia: The top subgroups are “B321 Residential non-aggravated burglary”, at 273, followed by “B322 Non-residential non-aggravated burglary” at 248.

Are any of these offences increasing over time?

Amelia: We take the crime data, then group by year, and count the number of offences in each year. We then plot this data. On the x axis we have year. On the y axis we have n, the number of crimes that take place in a subgroup in a year, and we are colouring according to the offence subgroup, and drawing this with a line, then making sure that the limits go from 0 to 30.

Amelia: This shows us that the most common offence is “residential non-aggravated burglary”,

The offenses which are most prominently increasing as illustrated in the graph over time consist of B321: residential non-aggravated burglary and B322: non-residential non-aggravated burglary. Further B312: non-residential aggravated burglary is on a steady incline between 2016 and 2017 It is evident that B311: residential aggravated burglary is decreasing from approximately 18 counts in 2017 to just under 15 counts in 2018. Similarly, B329: unknown non-aggravated burglary was significant in 2009 at approximately 14 counts, but is only at a low point of 1-2 in 2017.

What are the most common items stolen in Monash?

Cash/Document.

Amelia: We count up the item subdivisions, which is the smallest category on items. We then plot number of times an item is stolen, and reorder the y axis so that the items are in order of most to least.

Amelia:

Using all the crime data, what are the top 5 local government areas for total burglaries?

Amelia: This could be where we focus our next marketing campaign! Let’s take the crime data, then count the number of rows in each local_cov_area, and take the top 5 results using top_n, and arrange in descending order by the column “n”

## Selecting by n
## # A tibble: 5 x 2
##   local_gov_area      n
##   <chr>           <int>
## 1 Victoria         1335
## 2 Casey             831
## 3 Wyndham           830
## 4 Greater Geelong   828
## 5 Brimbank          817

(**) Which LGA had the most crime? (0.5 Mark) (**)

It appears Casey as an LGA had the most crime. Casey is chosen over Victoria as Victoria is not a local government area and is most likely the option selected when the cases’ location cannot be linked to a specific LGA or is unknown. Hence the Casey data is more appropriate for analysis.

** Subset the data to be the LGA with the most crime. (0.5 Mark) **

Repeat the previous analysis, but compare Monash with the rest of the data.

** Is crime in Casey increasing? (1 Mark) **

It appears relatively stable around the 85 count. However, there was a peak in crime in 2014, which is followed by a trend of increase in the following years.

** What are the most common offences at Casey across all years? (1 Marks) **

Residential B321 at 290 cases followed by non-residential burglary B322 at 255 cases.

## # A tibble: 5 x 2
##   offence_subgroup                                 n
##   <chr>                                        <int>
## 1 B311 Residential aggravated burglary           181
## 2 B312 Non-residential aggravated burglary        12
## 3 B321 Residential non-aggravated burglary       290
## 4 B322 Non-residential non-aggravated burglary   255
## 5 B329 Unknown non-aggravated burglary            93

** Are any of these offences increasing over time? (1 Mark) **

Amelia: I would write three sentences complete about what I learn in this graphic. You should start with a quick summary of what the graphic shows you. Then, describe what is on the x axis, the y axis, and any other colours used to separate the data. You then need to describe what you learn.

A summary of the number of burglaries for each year from 2009 until 2018, separated into individual lines for their offence subgroups. On the x axis is each year, and the y axis is the number of burglaries. We learn that there are no major changes in numbers in subgroups of offence except for a decrease in the unknown burglaries in the recent years and a steady increase in residential aggravated burglar and a steady decrease in unknown non-aggravated burglary until 2017 where there is a sudden increase

What are the most common subdivision items stolen in Casey?

Other electrical appliances followed by personal property and other property items.

Combine Monash with the top crime LGA area into one data set using bind_rows()

Amelia: You can stack the data together using bind_rows().

Amelia: Use ggplot to create two separate plots for each local government area using facet_wrap() on local government area.

** Do you have any recommendations about future directions with this dataset? Is there anything else in the excel spreadsheet we could look at? (2 Mark) **

Amelia: I was planning on looking at the other tabs in the spreadsheet to help us use information on the tool used to break in. How could we use what is in there? And what is in there that looks useful?

Table 07 with time of the day and which day of the week may be an important aspect. The company may focus on making night vision surveillance cameras depending on the most common time burglaries occur. Table 04 offers method of entry, where the data can be used to determine what is the most useful addition to a home to prevent burglaries such as adding alarms to not only doors but also windows if they are being tampered, acting as a business opportunity to sell that security device. We may also use the statistics as advertisement to urge people in the area to buy the product. Table 05 reveals the tool used hence we can make products more difficult for specific tools to break through.

** For our presentation to stake holders, you get to pick one figure to show them, which of the ones above would you choose? Why? Recreate the figure below here and write 3 sentences about it (2.5 Marks) **

I would include the following figure:

This graph is a summary of item sub divisions and their numbers, separated into two colours that represent the areas Monash and Casey. The x axis is the number of cases that fall under that item subdivision. The y axis tells labels the different item sub-divisions. This graph tells us that Monash is similar to Casey in trend but there are subtle difference such as the fact that burglaries in Casey tend to focus more on electrical appliances as opposed to in Monash they are more interested in cash and documents, hence we can provide security devices that focus on such sub divisions such as safes. This would be particularly useful if the company is planning on expanding to Casey as electrical appliance security would be the centre strategy.

Amelia: Remember, when you are describing data visualisation, You should start with a quick summary of what the graphic shows you. Then, describe what is on the x axis, the y axis, and any other colours used to separate the data. You then need to describe what you learn.

Amelia: Remeber to include the graphic again below.

References

Amelia: I have got to remember to cite all the R packages that I have used, and any Stack Overflow questions, blog posts, text books, from online that I have used to help me answer questions.

Data downloaded from https://www.crimestatistics.vic.gov.au/download-data

Packages used (look for things which were loaded with library()): * ggplot2 * dplyr * …