library(dplyr)
library(ggplot2)
library(ggrepel)
library(purrr)
library(stringr)
library(tibble)
library(tidyr)
source("R/inaugural-corpus.R")
source("R/lesson-figures.R")
paragraphs <- inaugural_paragraphs()
state_lookup <- tibble(state = datasets::state.name) |>
arrange(desc(str_length(state)), state)
empty_matches <- function() {
tibble(
state = character(),
start = integer(),
end = integer(),
mention = character()
)
}
state_pattern <- function(state_name) {
regex(
paste0("\\b", str_replace_all(state_name, " ", "\\\\s+"), "\\b"),
ignore_case = FALSE
)
}
find_all_state_candidates <- function(text) {
state_lookup$state |>
map_dfr(\(state_name) {
locations <- str_locate_all(text, state_pattern(state_name))[[1]]
if (nrow(locations) == 0L) {
return(empty_matches())
}
tibble(
state = state_name,
start = as.integer(locations[, 1]),
end = as.integer(locations[, 2]),
mention = str_sub(text, start, end)
)
}) |>
arrange(start, desc(end - start), state)
}
choose_longest_nonoverlap <- function(candidates, text_length) {
if (nrow(candidates) == 0L) {
return(candidates)
}
kept <- rep(FALSE, nrow(candidates))
used_positions <- rep(FALSE, text_length)
for (row_number in seq_len(nrow(candidates))) {
span <- candidates$start[row_number]:candidates$end[row_number]
if (!any(used_positions[span])) {
kept[row_number] <- TRUE
used_positions[span] <- TRUE
}
}
candidates[kept, ]
}
find_state_matches <- function(text) {
find_all_state_candidates(text) |>
choose_longest_nonoverlap(nchar(text))
}
state_matches <- paragraphs |>
mutate(matches = map(paragraph, find_state_matches)) |>
filter(map_int(matches, nrow) > 0L) |>
select(
paragraph_id, speech_id, year, president, paragraph_words,
paragraph, matches
) |>
unnest(matches) |>
mutate(
match_key = str_c(paragraph_id, state, start, sep = ":"),
context = str_squish(str_sub(
paragraph,
pmax(1L, start - 70L),
pmin(nchar(paragraph), end + 70L)
))
)
naive_state_counts <- state_matches |>
summarise(
naive_matches = n(),
naive_speeches = n_distinct(speech_id),
.by = state
) |>
arrange(desc(naive_matches), state)Mapping place mentions
Review state-name matches before drawing them
Washington is the first problem in this map. In presidential speeches it can mean a person, a city, the federal government, or the state. The review below has to decide which readings are present.
Ben still wants a map from the speeches, but the name match is only the first step.
Locations on a map means more than finding a name. The reader has to decide whether the name really refers to a place, what place it means, what unit is being counted, and whether the basemap can honestly show it.
This lesson uses U.S. inaugural-address paragraphs and the state names bundled with R. The review rules and labels below are the author’s judgement after reading the matches in this corpus. They are not an independent geoparser.
This lesson shows how to:
- match U.S. state names with case-sensitive, whole-word rules;
- compare naive matches with reviewed readings;
- keep person, river, event, government, and pre-statehood readings off the map;
- count speeches with at least one reviewed state reading;
- draw symbols with area scaling instead of a choropleth; and
- state a basemap’s coverage and projection limits.
Match state names before reviewing them
The source data is the shared inaugural-address paragraph table used in earlier lessons. A paragraph and speech ID travel with every match. The matcher sorts state names from longest to shortest so West Virginia would be selected before Virginia when both could overlap.
| Matched name | Naive matches | Speeches with a match |
|---|---|---|
| Washington | 22 | 17 |
| Texas | 11 | 2 |
| Mississippi | 7 | 5 |
| Louisiana | 4 | 4 |
| New York | 3 | 2 |
| Virginia | 3 | 3 |
| Florida | 2 | 1 |
| Kansas | 2 | 1 |
| Nebraska | 2 | 2 |
| North Carolina | 2 | 2 |
| Pennsylvania | 2 | 2 |
| California | 1 | 1 |
| Iowa | 1 | 1 |
| Massachusetts | 1 | 1 |
| Missouri | 1 | 1 |
| Montana | 1 | 1 |
| Ohio | 1 | 1 |
| Oregon | 1 | 1 |
The naive table counts strings. It does not know whether Washington is a person, the city, or the state. That is the next step.
Review what each match means
The categories below were written after reading the 67 matches. Any residue that the rules do not explain is assigned to uncertain, not to the map.
Each review key combines the paragraph ID, the matched name, and the 1-based character start returned for that paragraph, so a label stays with its sentence when rows are reordered.
category_table <- tribble(
~category, ~meaning,
"person", "the state name is part of a person's name or title",
"city or federal government", "the name refers to Washington, DC, New York City, or federal power",
"event name", "the name belongs to a named meeting or conference",
"river", "the name refers to a river or river valley",
"territory or republic before statehood", "the text refers to land before it became a state",
"law or organisation name", "the name appears inside a law, congress, or organisation label",
"state or its people", "the text refers to the state, its residents, or someone from that state",
"uncertain", "the author could not assign a safer category after reading the context"
)
review_labels <- tribble(
~match_key, ~reading_category,
"1805-Jefferson-p06:Louisiana:317", "territory or republic before statehood",
"1805-Jefferson-p06:Mississippi:671", "river",
"1821-Monroe-p13:Florida:562", "territory or republic before statehood",
"1821-Monroe-p14:Mississippi:490", "river",
"1821-Monroe-p14:Florida:630", "territory or republic before statehood",
"1821-Monroe-p14:Mississippi:1229", "river",
"1821-Monroe-p26:Mississippi:86", "river",
"1821-Monroe-p26:Louisiana:404", "territory or republic before statehood",
"1825-Adams-p04:Mississippi:102", "river",
"1845-Polk-p21:Texas:17", "territory or republic before statehood",
"1845-Polk-p21:Texas:194", "territory or republic before statehood",
"1845-Polk-p22:Texas:87", "territory or republic before statehood",
"1845-Polk-p22:Texas:916", "territory or republic before statehood",
"1845-Polk-p23:Texas:4", "territory or republic before statehood",
"1845-Polk-p24:Louisiana:329", "territory or republic before statehood",
"1845-Polk-p25:Texas:67", "territory or republic before statehood",
"1845-Polk-p25:Texas:260", "territory or republic before statehood",
"1845-Polk-p25:Texas:719", "territory or republic before statehood",
"1845-Polk-p25:Texas:1052", "territory or republic before statehood",
"1845-Polk-p25:Texas:1646", "territory or republic before statehood",
"1845-Polk-p26:Oregon:231", "territory or republic before statehood",
"1845-Polk-p26:Mississippi:627", "river",
"1845-Polk-p26:Missouri:667", "river",
"1849-Taylor-p07:Washington:216", "person",
"1853-Pierce-p03:North Carolina:342", "state or its people",
"1853-Pierce-p14:Washington:578", "person",
"1857-Buchanan-p06:Kansas:83", "territory or republic before statehood",
"1857-Buchanan-p08:Nebraska:425", "law or organisation name",
"1857-Buchanan-p08:Kansas:434", "law or organisation name",
"1857-Buchanan-p17:California:696", "state or its people",
"1857-Buchanan-p18:Washington:939", "person",
"1857-Buchanan-p19:Texas:169", "territory or republic before statehood",
"1877-Hayes-p01:Washington:78", "person",
"1885-Cleveland-p11:Washington:687", "person",
"1889-Harrison-p03:Washington:184", "person",
"1889-Harrison-p03:New York:209", "city or federal government",
"1889-Harrison-p03:New York:599", "city or federal government",
"1889-Harrison-p05:Washington:203", "person",
"1889-Harrison-p06:Virginia:94", "state or its people",
"1889-Harrison-p10:Pennsylvania:349", "state or its people",
"1889-Harrison-p29:Montana:116", "territory or republic before statehood",
"1889-Harrison-p29:Washington:128", "territory or republic before statehood",
"1897-McKinley-p14:Washington:321", "person",
"1897-McKinley-p14:Washington:1622", "city or federal government",
"1905-Roosevelt-p04:Washington:1135", "person",
"1909-Taft-p14:Ohio:956", "river",
"1909-Taft-p14:Mississippi:971", "river",
"1925-Coolidge-p07:Washington:190", "event name",
"1941-Roosevelt-p23:Washington:118", "person",
"1953-Eisenhower-p21:Iowa:156", "state or its people",
"1973-Nixon-p17:Washington:216", "city or federal government",
"1981-Reagan-p22:Massachusetts:155", "law or organisation name",
"1981-Reagan-p31:Washington:67", "person",
"1985-Reagan-p01:Louisiana:80", "state or its people",
"1985-Reagan-p03:Washington:144", "person",
"1985-Reagan-p13:Virginia:64", "state or its people",
"1989-Bush-p02:Washington:61", "person",
"1989-Bush-p02:Washington:195", "person",
"1989-Bush-p02:Washington:292", "person",
"1993-Clinton-p04:Washington:13", "person",
"2001-Bush-p28:Virginia:51", "state or its people",
"2017-Trump-p03:Washington:207", "city or federal government",
"2017-Trump-p18:Nebraska:87", "state or its people",
"2025-Trump-p10:North Carolina:118", "state or its people",
"2025-Trump-p17:Pennsylvania:39", "state or its people",
"2025-Trump-p56:New York:6", "city or federal government",
"2025-Trump-p56:Washington:114", "city or federal government"
)
review_matches <- state_matches |>
left_join(
review_labels,
by = join_by(match_key),
relationship = "one-to-one"
) |>
mutate(
reviewed_state_reading = reading_category == "state or its people"
)
label_preview <- review_labels |>
slice_head(n = 8)
category_counts <- category_table |>
left_join(
review_matches |>
count(reading_category, name = "matches"),
by = join_by(category == reading_category)
) |>
mutate(matches = coalesce(matches, 0L))| Match key | Reviewed category |
|---|---|
| 1805-Jefferson-p06:Louisiana:317 | territory or republic before statehood |
| 1805-Jefferson-p06:Mississippi:671 | river |
| 1821-Monroe-p13:Florida:562 | territory or republic before statehood |
| 1821-Monroe-p14:Mississippi:490 | river |
| 1821-Monroe-p14:Florida:630 | territory or republic before statehood |
| 1821-Monroe-p14:Mississippi:1229 | river |
| 1821-Monroe-p26:Mississippi:86 | river |
| 1821-Monroe-p26:Louisiana:404 | territory or republic before statehood |
| Review category | How this lesson uses the category | Matches |
|---|---|---|
| person | the state name is part of a person’s name or title | 16 |
| city or federal government | the name refers to Washington, DC, New York City, or federal power | 7 |
| event name | the name belongs to a named meeting or conference | 1 |
| river | the name refers to a river or river valley | 9 |
| territory or republic before statehood | the text refers to land before it became a state | 20 |
| law or organisation name | the name appears inside a law, congress, or organisation label | 3 |
| state or its people | the text refers to the state, its residents, or someone from that state | 11 |
| uncertain | the author could not assign a safer category after reading the context | 0 |
The category table is a disclosure, not a score. These labels were shaped by this corpus. A new collection would need a new review.
Compare naive and reviewed readings
The table below keeps the naive counts beside the reviewed counts. The reviewed unit is speeches with at least one state reading for a state. Repeated mentions inside one speech do not add more weight.
reviewed_state_counts <- review_matches |>
filter(reviewed_state_reading) |>
distinct(state, speech_id) |>
count(state, name = "reviewed_state_speeches") |>
arrange(desc(reviewed_state_speeches), state)
naive_review_comparison <- naive_state_counts |>
left_join(reviewed_state_counts, by = join_by(state)) |>
mutate(reviewed_state_speeches = coalesce(reviewed_state_speeches, 0L)) |>
arrange(desc(naive_matches), state)
washington_summary <- review_matches |>
filter(state == "Washington") |>
summarise(
matches = n(),
speeches = n_distinct(speech_id),
reviewed_state_speeches = n_distinct(speech_id[reviewed_state_reading])
)
river_summary <- review_matches |>
filter(state %in% c("Mississippi", "Ohio", "Missouri")) |>
summarise(
matches = n(),
speeches = n_distinct(speech_id),
categories = str_c(sort(unique(reading_category)), collapse = ", "),
.by = state
) |>
arrange(state)| Matched name | Naive matches | Naive speeches | Reviewed state speeches |
|---|---|---|---|
| Washington | 22 | 17 | 0 |
| Texas | 11 | 2 | 0 |
| Mississippi | 7 | 5 | 0 |
| Louisiana | 4 | 4 | 1 |
| New York | 3 | 2 | 0 |
| Virginia | 3 | 3 | 3 |
| Florida | 2 | 1 | 0 |
| Kansas | 2 | 1 | 0 |
| Nebraska | 2 | 2 | 1 |
| North Carolina | 2 | 2 | 2 |
| Pennsylvania | 2 | 2 | 2 |
| California | 1 | 1 | 1 |
| Iowa | 1 | 1 | 1 |
| Massachusetts | 1 | 1 | 0 |
| Missouri | 1 | 1 | 0 |
| Montana | 1 | 1 | 0 |
| Ohio | 1 | 1 | 0 |
| Oregon | 1 | 1 | 0 |
| Matched name | Matches | Speeches | Reviewed category |
|---|---|---|---|
| Mississippi | 7 | 5 | river |
| Missouri | 1 | 1 | river |
| Ohio | 1 | 1 | river |
The code finds Washington in 17 speeches and the review counts none as Washington State. It also finds Mississippi, Ohio, and Missouri as river readings. Those names stay in the review tables and stay off the map.
The full review table is long because every non-state reading remains visible.
review_table <- review_matches |>
transmute(
paragraph_id,
start,
state,
speech_id,
year,
president,
reading_category,
reviewed_state_reading,
context
) |>
arrange(paragraph_id, start, state)| Paragraph ID | Character start | Matched name | Speech ID | Year | President | Reviewed category | Mapped as state | Reading context |
|---|---|---|---|---|---|---|---|---|
| 1805-Jefferson-p06 | 317 | Louisiana | 1805-Jefferson | 1805 | Thomas Jefferson | territory or republic before statehood | FALSE | place the advances we shall have made. I know that the acquisition of Louisiana had been disapproved by some from a candid apprehension that the enla |
| 1805-Jefferson-p06 | 671 | Mississippi | 1805-Jefferson | 1805 | Thomas Jefferson | river | FALSE | sions; and in any view is it not better that the opposite bank of the Mississippi should be settled by our own brethren and children than by strangers |
| 1821-Monroe-p13 | 562 | Florida | 1821-Monroe | 1821 | James Monroe | territory or republic before statehood | FALSE | nd in 1817, and by the occurrences which took place in other parts of Florida in 1818, the details of which in both instances are too well known to |
| 1821-Monroe-p14 | 490 | Mississippi | 1821-Monroe | 1821 | James Monroe | river | FALSE | is established between the territories of the parties westward of the Mississippi, heretofore in dispute, has, it is thought, been settled on condition |
| 1821-Monroe-p14 | 630 | Florida | 1821-Monroe | 1821 | James Monroe | territory or republic before statehood | FALSE | n conditions just and advantageous to both. But to the acquisition of Florida too much importance can not be attached. It secures to the United Sta |
| 1821-Monroe-p14 | 1229 | Mississippi | 1821-Monroe | 1821 | James Monroe | river | FALSE | of war of the largest size. It covers by its position in the Gulf the Mississippi and other great waters within our extended limits, and thereby enable |
| 1821-Monroe-p26 | 86 | Mississippi | 1821-Monroe | 1821 | James Monroe | river | FALSE | tainments have not been less eminent. Twenty-five years ago the river Mississippi was shut up and our Western brethren had no outlet for their commerce |
| 1821-Monroe-p26 | 404 | Louisiana | 1821-Monroe | 1821 | James Monroe | territory or republic before statehood | FALSE | ams (with the exception of the upper part of the Red River only), but Louisiana, with a fair and liberal boundary on the western side and the Florida |
| 1825-Adams-p04 | 102 | Mississippi | 1825-Adams | 1825 | John Quincy Adams | river | FALSE | of four millions has multiplied to twelve. A territory bounded by the Mississippi has been extended from sea to sea. New States have been admitted to t |
| 1845-Polk-p21 | 17 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | The Republic of Texas has made known her desire to come into our Union, to form a part of o |
| 1845-Polk-p21 | 194 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | the blessings of liberty secured and guaranteed by our Constitution. Texas was once a part of our country - was unwisely ceded away to a foreign |
| 1845-Polk-p22 | 87 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | stion of annexation as belonging exclusively to the United States and Texas. They are independent powers competent to contract, and foreign natio |
| 1845-Polk-p22 | 916 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | an pacific. Foreign powers should therefore look on the annexation of Texas to the United States not as the conquest of a nation seeking to exten |
| 1845-Polk-p23 | 4 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | To Texas the reunion is important, because the strong protecting arm of our Go |
| 1845-Polk-p24 | 329 | Louisiana | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | ur boundaries. These objections were earnestly urged when we acquired Louisiana. Experience has shown that they were not well founded. The title of n |
| 1845-Polk-p25 | 67 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | None can fail to see the danger to our safety and future peace if Texas remains an independent state or becomes an ally or dependency of some |
| 1845-Polk-p25 | 260 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | here one among our citizens who would not prefer perpetual peace with Texas to occasional wars, which so often occur between bordering independen |
| 1845-Polk-p25 | 719 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | t of the Union? Whatever is good or evil in the local institutions of Texas will remain her own whether annexed to the United States or not. None |
| 1845-Polk-p25 | 1052 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | same principle that they would refuse to form a perpetual union with Texas because of her local institutions our forefathers would have been pre |
| 1845-Polk-p25 | 1646 | Texas | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | the people and Government of the United States by the reannexation of Texas to our Union at the earliest practicable period. |
| 1845-Polk-p26 | 231 | Oregon | 1845-Polk | 1845 | James Knox Polk | territory or republic before statehood | FALSE | hich lies beyond the Rocky Mountains. Our title to the country of the Oregon is "clear and unquestionable," and already are our people preparing t |
| 1845-Polk-p26 | 627 | Mississippi | 1845-Polk | 1845 | James Knox Polk | river | FALSE | e, increasing to many millions, have filled the eastern valley of the Mississippi, adventurously ascended the Missouri to its headsprings, and are alre |
| 1845-Polk-p26 | 667 | Missouri | 1845-Polk | 1845 | James Knox Polk | river | FALSE | led the eastern valley of the Mississippi, adventurously ascended the Missouri to its headsprings, and are already engaged in establishing the bless |
| 1849-Taylor-p07 | 216 | Washington | 1849-Taylor | 1849 | Zachary Taylor | person | FALSE | warned by the admonitions of history and the voice of our own beloved Washington to abstain from entangling alliances with foreign nations. In all dis |
| 1853-Pierce-p03 | 342 | North Carolina | 1853-Pierce | 1853 | Franklin Pierce | state or its people | TRUE | s Country made "the" then "recent accession of the important State of North Carolina to the Constitution of the United States" one of the subjects of his |
| 1853-Pierce-p14 | 578 | Washington | 1853-Pierce | 1853 | Franklin Pierce | person | FALSE | en slopes of Monticello, and, as it were, within reach of the tomb of Washington, with all the cherished memories of the past gathering around me like |
| 1857-Buchanan-p06 | 83 | Kansas | 1857-Buchanan | 1857 | James Buchanan | territory or republic before statehood | FALSE | consequence, Congress has also prescribed that when the Territory of Kansas shall be admitted as a State it "shall be received into the Union wit |
| 1857-Buchanan-p08 | 425 | Nebraska | 1857-Buchanan | 1857 | James Buchanan | law or organisation name | FALSE | may be, though it has ever been my individual opinion that under the Nebraska-Kansas act the appropriate period will be when the number of actual r |
| 1857-Buchanan-p08 | 434 | Kansas | 1857-Buchanan | 1857 | James Buchanan | law or organisation name | FALSE | though it has ever been my individual opinion that under the Nebraska-Kansas act the appropriate period will be when the number of actual resident |
| 1857-Buchanan-p17 | 696 | California | 1857-Buchanan | 1857 | James Buchanan | state or its people | TRUE | ainst invasion." Now, how is it possible to afford this protection to California and our Pacific possessions except by means of a military road throug |
| 1857-Buchanan-p18 | 939 | Washington | 1857-Buchanan | 1857 | James Buchanan | person | FALSE | gling alliances has been a maxim of our policy ever since the days of Washington, and its wisdom's no one will attempt to dispute. In short, we ought |
| 1857-Buchanan-p19 | 169 | Texas | 1857-Buchanan | 1857 | James Buchanan | territory or republic before statehood | FALSE | acquired any territory except by fair purchase or, as in the case of Texas, by the voluntary determination of a brave, kindred, and independent |
| 1877-Hayes-p01 | 78 | Washington | 1877-Hayes | 1877 | Rutherford B. Hayes | person | FALSE | citizens, we have assembled to repeat the public ceremonial, begun by Washington, observed by all my predecessors, and now a time-honored custom, whic |
| 1885-Cleveland-p11 | 687 | Washington | 1885-Cleveland | 1885 | Grover Cleveland | person | FALSE | and repelling their intrusion here. It is the policy of Monroe and of Washington and Jefferson - "Peace, commerce, and honest friendship with all nati |
| 1889-Harrison-p03 | 184 | Washington | 1889-Harrison | 1889 | Benjamin Harrison | person | FALSE | nty-sixth under our Constitution. The first inauguration of President Washington took place in New York, where Congress was then sitting, on the 30th |
| 1889-Harrison-p03 | 209 | New York | 1889-Harrison | 1889 | Benjamin Harrison | city or federal government | FALSE | itution. The first inauguration of President Washington took place in New York, where Congress was then sitting, on the 30th day of April, 1789, hav |
| 1889-Harrison-p03 | 599 | New York | 1889-Harrison | 1889 | Benjamin Harrison | city or federal government | FALSE | nd of the adoption of the Constitution, and will shortly celebrate in New York the institution of the second great department of our constitutional |
| 1889-Harrison-p05 | 203 | Washington | 1889-Harrison | 1889 | Benjamin Harrison | person | FALSE | , or to find inspiration and guidance in the teachings and example of Washington and his great associates, and hope and courage in the contrast which |
| 1889-Harrison-p06 | 94 | Virginia | 1889-Harrison | 1889 | Benjamin Harrison | state or its people | TRUE | has now a population greater than any of the original States (except Virginia) and greater than the aggregate of five of the smaller States in 1790 |
| 1889-Harrison-p10 | 349 | Pennsylvania | 1889-Harrison | 1889 | Benjamin Harrison | state or its people | TRUE | n fabrics. There was this reason only why the States that divide with Pennsylvania the mineral treasures of the great southeastern and central mountain |
| 1889-Harrison-p29 | 116 | Montana | 1889-Harrison | 1889 | Benjamin Harrison | territory or republic before statehood | FALSE | is a near prospect of the admission into the Union of the Dakotas and Montana and Washington Territories. This act of justice has been unreasonably |
| 1889-Harrison-p29 | 128 | Washington | 1889-Harrison | 1889 | Benjamin Harrison | territory or republic before statehood | FALSE | ospect of the admission into the Union of the Dakotas and Montana and Washington Territories. This act of justice has been unreasonably delayed in the |
| 1897-McKinley-p14 | 321 | Washington | 1897-McKinley | 1897 | William McKinley | person | FALSE | nterference with affairs of foreign governments wisely inaugurated by Washington, keeping ourselves free from entanglement, either as allies or foes, |
| 1897-McKinley-p14 | 1622 | Washington | 1897-McKinley | 1897 | William McKinley | city or federal government | FALSE | arbitration between the United States and Great Britain was signed at Washington and transmitted to the Senate for its ratification in January last. S |
| 1905-Roosevelt-p04 | 1135 | Washington | 1905-Roosevelt | 1905 | Theodore Roosevelt | person | FALSE | al, which made great the men who founded this Republic in the days of Washington, which made great the men who preserved this Republic in the days of |
| 1909-Taft-p14 | 956 | Ohio | 1909-Taft | 1909 | William Howard Taft | river | FALSE | and control of the channel of a great river system, like that of the Ohio or of the Mississippi, when definite and practical plans for the ente |
| 1909-Taft-p14 | 971 | Mississippi | 1909-Taft | 1909 | William Howard Taft | river | FALSE | the channel of a great river system, like that of the Ohio or of the Mississippi, when definite and practical plans for the enterprise have been appro |
| 1925-Coolidge-p07 | 190 | Washington | 1925-Coolidge | 1925 | Calvin Coolidge | event name | FALSE | es and consultations. We have before us the beneficial results of the Washington conference and the various consultations recently held upon European |
| 1941-Roosevelt-p23 | 118 | Washington | 1941-Roosevelt | 1941 | Franklin D. Roosevelt | person | FALSE | mothered with doubt and fear - then we shall reject the destiny which Washington strove so valiantly and so triumphantly to establish. The preservatio |
| 1953-Eisenhower-p21 | 156 | Iowa | 1953-Eisenhower | 1953 | Dwight D. Eisenhower | state or its people | TRUE | on bond binds the grower of rice in Burma and the planter of wheat in Iowa, the shepherd in southern Italy and the mountaineer in the Andes. It |
| 1973-Nixon-p17 | 216 | Washington | 1973-Nixon | 1973 | Richard Milhous Nixon | city or federal government | FALSE | consequences of attempting to gather all power and responsibility in Washington. |
| 1981-Reagan-p22 | 155 | Massachusetts | 1981-Reagan | 1981 | Ronald Reagan | law or organisation name | FALSE | atest among the Founding Fathers, Dr. Joseph Warren, President of the Massachusetts Congress, said to his fellow Americans, "Our country is in danger, bu |
| 1981-Reagan-p31 | 67 | Washington | 1981-Reagan | 1981 | Ronald Reagan | person | FALSE | Directly in front of me, the monument to a monumental man: George Washington, Father of our country. A man of humility who came to greatness reluc |
| 1985-Reagan-p01 | 80 | Louisiana | 1985-Reagan | 1985 | Ronald Reagan | state or its people | TRUE | however, one who is not with us today: Representative Gillis Long of Louisiana left us last night. I wonder if we could all join in a moment of sile |
| 1985-Reagan-p03 | 144 | Washington | 1985-Reagan | 1985 | Ronald Reagan | person | FALSE | e celebrated this historic occasion. When the first President, George Washington, placed his hand upon the Bible, he stood less than a single day's jo |
| 1985-Reagan-p13 | 64 | Virginia | 1985-Reagan | 1985 | Ronald Reagan | state or its people | TRUE | Two of our Founding Fathers, a Boston lawyer named Adams and a Virginia planter named Jefferson, members of that remarkable group who met in |
| 1989-Bush-p02 | 61 | Washington | 1989-Bush | 1989 | George Bush | person | FALSE | I have just repeated word for word the oath taken by George Washington 200 years ago, and the Bible on which I placed my hand is the Bible o |
| 1989-Bush-p02 | 195 | Washington | 1989-Bush | 1989 | George Bush | person | FALSE | d is the Bible on which he placed his. It is right that the memory of Washington be with us today, not only because this is our Bicentennial Inaugurat |
| 1989-Bush-p02 | 292 | Washington | 1989-Bush | 1989 | George Bush | person | FALSE | , not only because this is our Bicentennial Inauguration, but because Washington remains the Father of our Country. And he would, I think, be gladdene |
| 1993-Clinton-p04 | 13 | Washington | 1993-Clinton | 1993 | Bill Clinton | person | FALSE | When George Washington first took the oath I have just sworn to uphold, news travelled slowl |
| 2001-Bush-p28 | 51 | Virginia | 2001-Bush | 2001 | George W. Bush | state or its people | TRUE | After the Declaration of Independence was signed, Virginia statesman John Page wrote to Thomas Jefferson: "We know the race is n |
| 2017-Trump-p03 | 207 | Washington | 2017-Trump | 2017 | Donald J. Trump | city or federal government | FALSE | er, or from one party to another - but we are transferring power from Washington DC and giving it back to you, the people. |
| 2017-Trump-p18 | 87 | Nebraska | 2017-Trump | 2017 | Donald J. Trump | state or its people | TRUE | ild is born in the urban sprawl of Detroit or the windswept plains of Nebraska, they look up at the same night sky, they fill their heart with the s |
| 2025-Trump-p10 | 118 | North Carolina | 2025-Trump | 2025 | Donald J. Trump | state or its people | TRUE | s in times of emergency, as recently shown by the wonderful people of North Carolina — who have been treated so badly — (applause) — and other states who |
| 2025-Trump-p17 | 39 | Pennsylvania | 2025-Trump | 2025 | Donald J. Trump | state or its people | TRUE | Just a few months ago, in a beautiful Pennsylvania field, an assassin’s bullet ripped through my ear. But I felt then an |
| 2025-Trump-p56 | 6 | New York | 2025-Trump | 2025 | Donald J. Trump | city or federal government | FALSE | From New York to Los Angeles, from Philadelphia to Phoenix, from Chicago to Miami, |
| 2025-Trump-p56 | 114 | Washington | 2025-Trump | 2025 | Donald J. Trump | city or federal government | FALSE | phia to Phoenix, from Chicago to Miami, from Houston to right here in Washington, D.C., our country was forged and built by the generations of patriot |
Draw the reviewed state counts
The basemap comes from ggplot2::map_data("state"), which uses the maps package state database. That database covers the 48 contiguous states and the District of Columbia. It does not draw Alaska or Hawaii, and this lesson does not plot their state.center points.
lower48_map <- ggplot2::map_data("state")
state_centers <- tibble(
state = datasets::state.name,
longitude = datasets::state.center$x,
latitude = datasets::state.center$y
) |>
mutate(lower48_or_dc = !state %in% c("Alaska", "Hawaii"))
map_points <- reviewed_state_counts |>
left_join(state_centers, by = join_by(state)) |>
filter(lower48_or_dc)| State | Speeches with reviewed state reading | Approximate center longitude | Approximate center latitude |
|---|---|---|---|
| Virginia | 3 | -78.2005 | 37.5630 |
| North Carolina | 2 | -78.4686 | 35.4195 |
| Pennsylvania | 2 | -77.4500 | 40.9069 |
| California | 1 | -119.7730 | 36.5341 |
| Iowa | 1 | -93.3714 | 41.9358 |
| Louisiana | 1 | -92.2724 | 30.6181 |
| Nebraska | 1 | -99.5898 | 41.3356 |
The coordinates are approximate state centers. A symbol at a center is a count marker, not the place where a speech event happened. A choropleth shades whole areas by value; this map uses circles instead because the values are small counts of speeches, not rates or attention. Pre-statehood references such as the Republic of Texas were not counted as state readings.
Each circle carries its state name and count as a label, so the map needs no size legend. ggrepel places those labels so they do not collide, and its seed keeps the placement the same on every render. Washington gets a note instead of a circle, because the review is the reason it is missing.
mean_latitude <- mean(lower48_map$lat, na.rm = TRUE)
fixed_ratio <- 1 / cos(mean_latitude * pi / 180)
map_labels <- map_points |>
mutate(
label = str_c(state, " ", reviewed_state_speeches),
# Circle diameter from scale_size_area(), so labels clear the circle.
circle_size = 11 * sqrt(reviewed_state_speeches / max(reviewed_state_speeches))
)
washington_note <- state_centers |>
filter(state == "Washington") |>
mutate(
label = str_c(
"Washington: ", washington_summary$matches, " name matches,\n",
"none about the state"
)
)
ggplot() +
geom_polygon(
data = lower48_map,
aes(x = long, y = lat, group = group),
fill = "#EEF1F4",
colour = lesson_colours[["paper"]],
linewidth = 0.4
) +
geom_point(
data = map_points,
aes(x = longitude, y = latitude, size = reviewed_state_speeches),
shape = 21,
fill = lesson_colours[["accent"]],
colour = lesson_colours[["paper"]],
stroke = 0.8,
alpha = 0.9
) +
geom_text_repel(
data = map_labels,
aes(x = longitude, y = latitude, label = label, point.size = circle_size),
family = lesson_font,
size = 3.6,
colour = lesson_colours[["ink"]],
seed = 8001,
box.padding = 0.4,
point.padding = 0.15,
min.segment.length = 0,
segment.colour = lesson_colours[["muted"]],
segment.size = 0.3,
max.overlaps = Inf
) +
geom_text(
data = washington_note,
aes(x = longitude, y = latitude, label = label),
family = lesson_font,
size = 3.3,
hjust = 0,
lineheight = 0.95,
colour = lesson_colours[["muted"]]
) +
scale_size_area(max_size = 11, guide = "none") +
coord_fixed(ratio = fixed_ratio, clip = "off") +
labs(
title = "After review, only seven states remain on the map",
subtitle = str_c(
"Speeches with at least one reviewed reading of each state; ",
"circle area shows the count"
),
caption = str_c(
"Circles sit at approximate state centres from datasets::state.center. ",
"Alaska and Hawaii are not on this basemap."
)
) +
theme_lesson(grid = "none") +
theme(
axis.text = element_blank(),
axis.title = element_blank()
)
The coordinate ratio is 1 / cos(mean latitude in radians), which is 1.27 in this render. One degree of latitude is drawn about 1.27 times as long as one degree of longitude, because a degree of longitude covers less ground away from the equator. Near the middle of the country, a mile east-west and a mile north-south then look about the same length. This does not preserve area. The circle areas encode the speech counts; exact values belong in the table.
Where this fits
Lesson 30 shows how a gazetteer can turn a place name into coordinates. This page begins earlier. It asks whether a matched name should become a place record at all. Names can refer to people, laws, rivers, cities, events, governments, or places from an earlier political period.
The lower-48 map also has coverage limits. If a reviewed state reading pointed to Alaska or Hawaii, this page would keep it in the table and not draw it on this basemap.
What to remember
- A state-name match is not automatically a state reference.
- Review labels shaped after reading the matches must be disclosed.
- Count speeches, not repeated mentions, when the unit is speeches.
- Rivers, people, events, and pre-statehood references stay off the reviewed map.
scale_size_area()maps values to circle area; the table carries exact counts.- A lower-48 basemap cannot show every U.S. state.
Ben can map seven reviewed states, but only after most naive matches have been kept out of the symbol layer. The table is part of the map because it shows what the picture refused to draw.