# NOT RUN {
if(requireNamespace("ggplot2") && requireNamespace("data.table") &&
requireNamespace("lubridate")) {
# Load data
url1 <- "https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data1.csv"
ridesRaw_1 <- url1 %>%
data.table::fread(stringsAsFactors = FALSE)
url2 <- "https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data2.csv"
ridesRaw_2 <- url2 %>%
data.table::fread(stringsAsFactors = FALSE)
url3 <- "https://raw.githubusercontent.com/plotly/datasets/master/uber-rides-data3.csv"
ridesRaw_3 <- url3 %>%
data.table::fread(stringsAsFactors = FALSE)
ridesDf <- list(ridesRaw_1, ridesRaw_2, ridesRaw_3) %>%
data.table::rbindlist()
time <- lubridate::ymd_hms(ridesDf$`Date/Time`)
ridesDf <- ridesDf[, 'Date/Time':=NULL][, list(Lat,
Lon,
hour = lubridate::hour(time),
month = lubridate::month(time),
day = lubridate::day(time))]
# continuous variable legend
ggRasterly(data = ridesDf,
mapping = aes(x = Lat, y = Lon),
color = fire_map
)
# discreate variable legend
ggRasterly(data = ridesDf,
mapping = aes(x = Lat, y = Lon, color = hour),
color = hourColors_map
) +
ggplot2::labs(title = "New York Uber",
subtitle = "Apr to Sept, 2014",
caption =
"https://raw.githubusercontent.com/plotly/datasets/master")
}
# }
Run the code above in your browser using DataLab