── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.2.1 ✔ readr 2.2.0
✔ forcats 1.0.1 ✔ stringr 1.6.0
✔ ggplot2 4.0.2 ✔ tibble 3.3.1
✔ lubridate 1.9.5 ✔ tidyr 1.3.2
✔ purrr 1.2.1
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
library(terra)
terra 1.9.34
Attaching package: 'terra'
The following object is masked from 'package:tidyr':
extract
library(mapview)library(rnaturalearth)
Combining data frames of the same shape
bind_cols() and bind_rows() can combine two or more data frames
cbind() 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"
Rows: 931 Columns: 17
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): title, author, state
dbl (13): book_id, year, removed, explicit, antifamily, occult, language, l...
date (1): date
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
regions <- state.region |>recode("North Central"="Midwest")regions
[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
Rows: 55 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (1): STABR
dbl (9): POPU_LSA, POPU_ST, CENTLIB, BRANLIB, BKMOB, BKVOL, LIBRARIA, VISITS...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
lib_df |>summary()
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.