7.3.5 Visualization for Law and Order - Video 3 A Line Plot
In this video, we'll create a basic line plot to visualize crime trends. Let's start by reading in our data. We'll call it mvt for motor vehicle thefts, and use the read.csv function to read in the file mvt.csv. We'll add the argument stringsAsFactors = FALSE, since we have a text field, and we want to make sure it's read in properly. Let's take a look at the structure of our data using the str function. We have over 190,000 observations of three different variables-- the date of the crime, and the location of the crime, in terms of latitude and longitude. We want to first convert the Date variable to a format that R will recognize so that we can extract the day of the week and the hour of the day. We can do this using the strptime function. So we want to replace our variable, Date, with the output of the strptime function, which takes as a first argument our variable, Date, and then as a second argument the format that the date is in. Here, we can...