Chapter 4 Latitude and Longitude
The Location field has the format (Latitude,Longitude). We create 2 fields Latitude and Longitude from the Location field. We would be using these newly formed fields in the maps shown below.
LACrime_latlong = gsub('\\(','',LACrime$Location)
LACrime_latlong = gsub('\\)','',LACrime_latlong)
LACrime_latlong = str_split(LACrime_latlong,",")
LACrime_latlong = do.call(rbind.data.frame, LACrime_latlong)
colnames(LACrime_latlong) = c("latitude","longitude")
LACrime$latitude = as.numeric(as.character(LACrime_latlong$latitude))
LACrime$longitude = as.numeric(as.character(LACrime_latlong$longitude))
rm(LACrime_latlong)
LACrime = LACrime %>%
select(-Location)