context("geom_timeline_label")
library(ggplot2)
dt <- structure(list(COUNTRY = rep("MAA", 5),
LOCATION_NAME = c("Ankkalinna", "Mordor", "Korvatuntunturi", "Atlantis", "Oz"),
DATE = structure(c(1264774400, 1378993600, 1477993700, 1577993800, 1687993900),
class = c("POSIXct", "POSIXt"), tzone = "UTC"),
EQ_PRIMARY = c(8.3, 5.7, 1.1, 3.4, 6.6),
LATITUDE = c(38.381, 37.670, 41.789, 43.883, 44.329),
LONGITUDE = c(13.701, 15.267, 14.872, 11.961, 11.451),
DEATHS = c(4, 55, NA, 2, 78)),
.Names = c("COUNTRY", "LOCATION_NAME", "DATE", "EQ_PRIMARY", "LATITUDE", "LONGITUDE", "DEATHS"),
row.names = c(NA, 5L), class = "data.frame")
obj <- ggplot(dt) +
geom_timeline( aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, fill = DEATHS)) +
geom_timeline_label( aes(x = DATE, y = COUNTRY, label = LOCATION_NAME, n_max = 1, size = EQ_PRIMARY)) +
theme_eq
test_that("geom_timeline_label has two layers", {
expect_true(length(obj$layers) == 2)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.