Skip to content

Commit

Permalink
Rename vignette files
Browse files Browse the repository at this point in the history
  • Loading branch information
pdil committed Jan 19, 2024
1 parent 05c3fb2 commit 04f2c96
Show file tree
Hide file tree
Showing 12 changed files with 832 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* Add state abbreviation (`abbr`) column to `citypop` data set.
* Update and standardize documentation throughout the page.
* Includes updates to formatting, links, and language.
* Rename vignettes to make them easier to find and read in order.

### Bug Fixes
* `plot_usmap()` warnings have been cleaned up, including a defunct warning that didn't make sense.
Expand Down
6 changes: 3 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ To read the package vignettes, which explain helpful uses of the package, use `v

```{r vignettes, eval=FALSE}
vignette(package = "usmap")
vignette("introduction", package = "usmap")
vignette("mapping", package = "usmap")
vignette("advanced-mapping", package = "usmap")
vignette("usmap1", package = "usmap") # 1. Introduction
vignette("usmap2", package = "usmap") # 2. Mapping the US
vignette("usmap3", package = "usmap") # 3. Advanced Mapping
```

For further help with this package, open an [issue](https://github.com/pdil/usmap/issues) or ask a question on Stack Overflow with the [usmap tag](https://stackoverflow.com/questions/tagged/usmap).
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ package, use `vignette`:

``` r
vignette(package = "usmap")
vignette("introduction", package = "usmap")
vignette("mapping", package = "usmap")
vignette("advanced-mapping", package = "usmap")
vignette("usmap1", package = "usmap") # 1. Introduction
vignette("usmap2", package = "usmap") # 2. Mapping the US
vignette("usmap3", package = "usmap") # 3. Advanced Mapping
```

For further help with this package, open an
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
130 changes: 130 additions & 0 deletions vignettes/usmap2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
library(usmap)
library(ggplot2)

plot_usmap(regions = "counties") +
labs(title = "US Counties",
subtitle = "This is a blank map of the counties of the United States.") +
theme(panel.background = element_rect(color = "black", fill = "lightblue"))

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
library(usmap)
library(ggplot2)

plot_usmap(include = c("CA", "ID", "NV", "OR", "WA")) +
labs(title = "Western US States",
subtitle = "These are the states in the Pacific Timezone.")

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
library(usmap)
library(ggplot2)

plot_usmap(data = statepop, values = "pop_2015", color = "red") +
scale_fill_continuous(name = "Population (2015)", label = scales::comma) +
theme(legend.position = "right")

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
library(usmap)
library(ggplot2)

plot_usmap(data = statepop, values = "pop_2015", color = "red") +
scale_fill_continuous(
low = "white", high = "red", name = "Population (2015)", label = scales::comma
) + theme(legend.position = "right")

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
library(usmap)
library(ggplot2)

plot_usmap(
data = statepop, values = "pop_2015", include = c("CA", "ID", "NV", "OR", "WA"), color = "red"
) +
scale_fill_continuous(
low = "white", high = "red", name = "Population (2015)", label = scales::comma
) +
labs(title = "Western US States", subtitle = "These are the states in the Pacific Timezone.") +
theme(legend.position = "right")

## ----fig.show='hide', message=FALSE, warning=FALSE----------------------------
df <- data.frame(
fips = c("02", "01", "05", "04"),
values = c(14, 18, 19, 8)
)

plot_usmap(data = df)

## ----fig.show='hide', message=FALSE, warning=FALSE----------------------------
df <- data.frame(
fips = c("02", "01", "05", "04"),
population = c(14, 18, 19, 8)
)

plot_usmap(data = df, values = "population")

## ----fig.show='hide', message=FALSE, warning=FALSE----------------------------
df <- data.frame(
state = c("AL", "Alaska", "AR", "AZ"),
values = c(14, 18, 19, 8)
)

plot_usmap(data = df)

## ----fig.show='hide', message=FALSE, warning=FALSE----------------------------
df <- data.frame(
fips = c("10001", "10003", "10005"),
values = c(93, 98, 41)
)

plot_usmap(data = df)

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
usmap::plot_usmap(include = .south_region)

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
usmap::plot_usmap(include = .east_south_central)

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
usmap::plot_usmap(include = .south_region, exclude = .east_south_central)

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
usmap::plot_usmap("counties",
include = c(.south_region, "IA"),
exclude = c(.east_south_central, "12")) # 12 = FL

## ----fig.align='center', fig.width=7, message=FALSE, warning=FALSE------------
usmap::plot_usmap("counties", fill = "yellow", alpha = 0.25,
# 06065 = Riverside County, CA
include = c(.south_region, "IA", "06065"),
# 12 = FL, 48141 = El Paso County, TX
exclude = c(.east_south_central, "12", "48141"))

## -----------------------------------------------------------------------------
.new_england
.mid_atlantic
.east_north_central
.west_north_central
.south_atlantic
.east_south_central
.west_south_central
.mountain
.pacific

## -----------------------------------------------------------------------------
.northeast_region # c(.new_england, .mid_atlantic)
.north_central_region # c(.east_north_central, .west_north_central)
.midwest_region # .north_central_region (renamed in June 1984)
.south_region # c(.south_atlantic, .east_south_central, .west_south_central)
.west_region # c(.mountain, .pacific)

## -----------------------------------------------------------------------------
str(usmap::us_map())

## -----------------------------------------------------------------------------
str(usmap::us_map(regions = "counties"))

File renamed without changes.
Loading

0 comments on commit 04f2c96

Please sign in to comment.