knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This page provides an overview for the get_basedata()
function, highlighting some of its potential uses.
First things first—let's load the {troopdata}
package
library(troopdata) library(ggplot2) library(dplyr)
The troopdata package provides multiple functions to generate customizable datasets containing information on US military deployments and accompanying data. The get_basedata()
function represents the core of this package, providing customized data on US overseas troop deployments, specifically.
The second function, get_basedata()
returns a data frame containing information on the United States' overseas military bases going back to the beginning of the Cold War. At its most basic the function will return a data frame containing country-base observations, along with the facility's longitude and latitude (if available), and a series of binary variables indicating whether or not the facility is a full military base, a smaller lilypad, and if it is a currently funded site.
baseexample <- get_basedata(host = NA, country_count = FALSE) head(baseexample)
As with the get_troopdata()
function you can specify a numeric vector of COW country codes or a character vector of ISO3C codes to specify specific host countries.
For example, using COW country codes:
hostlist <- c(20, 200, 255, 645) baseexample <- get_basedata(host = hostlist, country_count = FALSE) head(baseexample)
And another using ISO3C codes:
hostlist.char <- c("CAN", "GBR", "PRI") baseexample <- get_basedata(host = hostlist.char, country_count = FALSE)
Finally, users can also generate country-level counts of the number of U.S. military bases by changing the country_count
argument to TRUE
. Note that when using this argument you also need to specify the groupvar
argument, which specifies which identifier will be used to generate country-level totals. Though this may sound obvious individual country codes may include multiple geographic territories that are more finely parsed using various identifiers. Accepted character strings include "countryname", "iso3c", and "ccode". And while this may seem redundant given the host argument, it should provide flexibility for users who may be more familiar with country codes and do not want to spend time trying to identify long-form country names.
hostlist <- c(20, 200, 255, 645) baseexample <- get_basedata(host = hostlist, country_count = TRUE, groupvar = "ccode") head(baseexample)
So what can you do with these super useful and cool data? Lots of things! The study of basing and military deployments has been picking up over the last few years and there are lots of cool studies you should check out. With these data you can do cool things like this!
library(ggplot2) map <- ggplot2::map_data("world") basepoints <- get_basedata(host = NA) basemap <- ggplot() + geom_polygon(data = map, aes(x = long, y = lat, group = group), fill = "gray80", color = "white", size = 0.1) + geom_point(data = basepoints, aes(x = lon, y = lat), color = "purple", alpha = 0.6) + coord_equal(ratio = 1.3) + theme_void() + theme(plot.title = element_text(face = "bold", size = 15)) + labs(title = "Locations of U.S. military facilities, 1950-2018") basemap
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.