PPOL 6805: GIS for Spatial Data Science
2026-10-09
bind_cols() and bind_rows() can combine two or more data framescbind() and rbind()division_df <- tibble(
division_str = c(
'New England', 'Middle Atlantic', 'East North Central',
'West North Central', 'South Atlantic', 'East South Central',
'West South Central', 'Mountain', 'Pacific'
)
)
division_code_df <- tibble(
division_code = 1:9
)
paste(
'Dimensions of division_df:', dim(division_df),
'Dimensions of division_code_df', dim(division_code_df)) |> print()[1] "Dimensions of division_df: 9 Dimensions of division_code_df 9"
[2] "Dimensions of division_df: 1 Dimensions of division_code_df 1"
bind_rows():[1] 39 3
[1] 47 2
| state | n | var |
|---|---|---|
| VA | 16 | not removed |
| VT | 13 | not removed |
| WA | 6 | not removed |
| WI | 7 | not removed |
| WV | 3 | not removed |
| WY | 3 | not removed |
| state | n | var |
|---|---|---|
| VA | 18 | removed |
| VT | 0 | removed |
| WA | 3 | removed |
| WI | 3 | removed |
| WV | 0 | removed |
| WY | 1 | removed |
| state | n | var |
|---|---|---|
| VA | 34 | all |
| VT | 13 | all |
| WA | 9 | all |
| WI | 10 | all |
| WV | 3 | all |
| WY | 4 | all |
| state | n | var |
|---|---|---|
| WV | 3 | all |
| WV | 0 | removed |
| WV | 3 | not removed |
| WY | 4 | all |
| WY | 1 | removed |
| WY | 3 | not removed |
left_join(), inner_join(), right_join(), full_join(), semi_join(), and anti_join(). [1] South West West South West West Northeast
[8] South South South West West Midwest Midwest
[15] Midwest Midwest South South Northeast South Northeast
[22] Midwest Midwest South Midwest West Midwest West
[29] Northeast Northeast West Northeast South Midwest Midwest
[36] South West Northeast Northeast South Midwest South
[43] South West Northeast South West South Midwest
[50] West
Levels: Northeast South Midwest West
left_join() retains the number of rows of the data frame on the left (x)
| state_abb | region_str | region_code |
|---|---|---|
| AL | South | 3 |
| AK | West | 4 |
| AZ | West | 4 |
| AR | South | 3 |
| CA | West | 4 |
| CO | West | 4 |
| CT | Northeast | 1 |
| DE | South | 3 |
| FL | South | 3 |
| GA | South | 3 |
| HI | West | 4 |
| ID | West | 4 |
| IL | Midwest | 2 |
| IN | Midwest | 2 |
| IA | Midwest | 2 |
| KS | Midwest | 2 |
| KY | South | 3 |
| LA | South | 3 |
| ME | Northeast | 1 |
| MD | South | 3 |
| MA | Northeast | 1 |
| MI | Midwest | 2 |
| MN | Midwest | 2 |
| MS | South | 3 |
| MO | Midwest | 2 |
| MT | West | 4 |
| NE | Midwest | 2 |
| NV | West | 4 |
| NH | Northeast | 1 |
| NJ | Northeast | 1 |
| NM | West | 4 |
| NY | Northeast | 1 |
| NC | South | 3 |
| ND | Midwest | 2 |
| OH | Midwest | 2 |
| OK | South | 3 |
| OR | West | 4 |
| PA | Northeast | 1 |
| RI | Northeast | 1 |
| SC | South | 3 |
| SD | Midwest | 2 |
| TN | South | 3 |
| TX | South | 3 |
| UT | West | 4 |
| VT | Northeast | 1 |
| VA | South | 3 |
| WA | West | 4 |
| WV | South | 3 |
| WI | Midwest | 2 |
| WY | West | 4 |
| name | geomtype | driver | features | fields | crs |
|---|---|---|---|---|---|
| tl_2010_us_state10 | Polygon | ESRI Shapefile | 52 | 14 | NAD83 , GEOGCRS[“NAD83”, |
DATUM["North American Datum 1983",
ELLIPSOID["GRS 1980",6378137,298.257222101,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4269]] |
Reading layer `tl_2010_us_state10' from data source
`/Users/jpj/gtown-local/ppol6805-workshop/w07/data/tl_2010_us_state10'
using driver `ESRI Shapefile'
Simple feature collection with 52 features and 14 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -179.2311 ymin: 17.83151 xmax: 179.8597 ymax: 71.44106
Geodetic CRS: NAD83
| REGION10 | DIVISION10 | GEOID10 | STUSPS10 | NAME10 | ALAND10 | AWATER10 | INTPTLAT10 | INTPTLON10 | geometry |
|---|---|---|---|---|---|---|---|---|---|
| 4 | 8 | 56 | WY | Wyoming | 251470069067 | 1864445306 | +42.9918024 | -107.5419255 | MULTIPOLYGON (((-108.6213 4… |
| 1 | 2 | 42 | PA | Pennsylvania | 115883064314 | 3397122731 | +40.9042486 | -077.8280624 | MULTIPOLYGON (((-80.51909 3… |
| 2 | 3 | 39 | OH | Ohio | 105828706692 | 10269012119 | +40.4149297 | -082.7119975 | MULTIPOLYGON (((-84.05271 3… |
| 4 | 8 | 35 | NM | New Mexico | 314160748240 | 756659673 | +34.4391265 | -106.1261511 | MULTIPOLYGON (((-109.0462 3… |
Coordinate Reference System:
User input: NAD83
wkt:
GEOGCRS["NAD83",
DATUM["North American Datum 1983",
ELLIPSOID["GRS 1980",6378137,298.257222101,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["latitude",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["longitude",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4269]]
STABR POPU_LSA POPU_ST CENTLIB
Length:55 Min. : 53883 Min. : 53883 Min. : 0.0
Class :character 1st Qu.: 1409268 1st Qu.: 1322416 1st Qu.: 54.5
Mode :character Median : 4141264 Median : 3751351 Median :100.0
Mean : 5595942 Mean : 5663819 Mean :165.7
3rd Qu.: 6540910 3rd Qu.: 6497622 3rd Qu.:234.0
Max. :38647288 Max. :38648090 Max. :755.0
BRANLIB BKMOB BKVOL LIBRARIA
Min. : 1.0 Min. : 0.00 Min. : -1 Min. : -1.0
1st Qu.: 28.5 1st Qu.: 2.00 1st Qu.: 4423164 1st Qu.: 206.1
Median : 83.0 Median : 7.00 Median : 9575400 Median : 587.0
Mean :140.1 Mean :13.44 Mean :14772714 Mean : 855.7
3rd Qu.:192.0 3rd Qu.:17.50 3rd Qu.:17074348 3rd Qu.:1063.4
Max. :942.0 Max. :81.00 Max. :74753745 Max. :4062.5
VISITS REGBOR
Min. : -1 Min. : -1
1st Qu.: 6216945 1st Qu.: 763359
Median : 18282842 Median : 1938999
Mean : 28628594 Mean : 3118459
3rd Qu.: 39948818 3rd Qu.: 4129365
Max. :178979300 Max. :22275618
Error:
!
oops! Arguments xcol and/or ycol are missing!
You probably expected lib_sf to be a spatial object.
However it is of class spec_tbl_df.
Either convert lib_sf to a spatial object or provide xcol and ycol.
oops! Arguments xcol and/or ycol are missing!
You probably expected lib_sf to be a spatial object.
However it is of class tbl_df.
Either convert lib_sf to a spatial object or provide xcol and ycol.
oops! Arguments xcol and/or ycol are missing!
You probably expected lib_sf to be a spatial object.
However it is of class tbl.
Either convert lib_sf to a spatial object or provide xcol and ycol.
oops! Arguments xcol and/or ycol are missing!
You probably expected lib_sf to be a spatial object.
However it is of class data.frame.
Either convert lib_sf to a spatial object or provide xcol and ycol.