add_data: Add data

Description Usage Arguments Examples

View source: R/add.R

Description

Add a dataset.

Usage

1

Arguments

p

a datamaps object.

data

data.frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"),
                     lon = c(-0.1167218, -73.98002, 116.3883, 151.18518),
                     lat = c(51.49999, 40.74998, 39.92889, -33.92001),
                     values = c(11, 23, 29 , 42))

data <- data.frame(name = c("USA", "FRA", "CHN", "RUS", "COG", "DZA",
                            "BRA", "AFG"),
    color = round(runif(8, 1, 10)))

edges <- data.frame(origin = c("USA", "FRA", "BGD", "ETH", "KHM", "GRD",
                               "FJI", "GNB", "AUT", "YEM"),
    target = c("BRA", "USA", "URY", "ZAF", "SAU", "SVK", "RWA", "SWE",
               "TUV", "ZWE"),
    strokeColor = rep(c("gray", "black"), 5))

data %>%
    datamaps(default = "lightgray") %>%
    add_choropleth(name, color) %>%
    add_data(coords) %>%
    add_bubbles(lon, lat, values, values, city, colors = c("skyblue", "darkblue")) %>%
    add_data(edges) %>%
    add_arcs_name(origin, target, strokeColor)

JohnCoene/datamaps documentation built on May 7, 2019, 11:58 a.m.