21.1 Tables from websites (wikipedia)
wiki_url <- RCurl::getURL("https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations")
tables <- XML::readHTMLTable(wiki_url)
abbrevs <- tables[[1]]
head(abbrevs)
## V1
## 1 Codes:
## 2 ISO
## 3 ANSI
## 4 USPS
## 5 USCG
## 6 Abbreviations:
## V2
## 1 <NA>
## 2 ISO 3166 codes (2-letter, 3-letter, and 3-digit codes from ISO 3166-1; 2+2-letter codes from ISO 3166-2)
## 3 2-letter and 2-digit codes from the ANSI standard INCITS 38:2009
## 4 2-letter codes used by the United States Postal Service
## 5 2-letter codes used by the United States Coast Guard (red text shows differences between ANSI and USCG)
## 6 <NA>
## V3 V4 V5 V6 V7 V8 V9 V10
## 1 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 2 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 3 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 4 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 5 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 6 <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
us <- abbrevs[11:nrow(abbrevs), ]
head(us)
## V1 V2 V3 V4 V5 V6 V7 V8
## 11 United States of America Federal state US\nUSA\n840 US 00 U.S.
## 12 Alabama State US-AL AL 01 AL AL Ala.
## 13 Alaska State US-AK AK 02 AK AK Alaska
## 14 Arizona State US-AZ AZ 04 AZ AZ Ariz.
## 15 Arkansas State US-AR AR 05 AR AR Ark.
## 16 California State US-CA CA 06 CA CF Calif.
## V9 V10
## 11 U.S. U.S.A.
## 12 Ala.
## 13 Alaska Alas.
## 14 Ariz. Az.
## 15 Ark.
## 16 Calif. Ca., Cal.
Write a test to make sure what you got is what you expect