state_from_sitetable - Identify US State that each site is in (given ST, FIPS, or lat/lon)
Source:R/state_from_sitetable.R
      state_from_sitetable.RdIdentify US State that each site is in (given ST, lat/lon, or FIPS)
Arguments
- sites
 data.frame or data.table, with one row per site, and column(s) that are either "ST" (2-letter abbreviation of State), "lat" and "lon", or "fips" or "bgfips" and optionally a column like "ejam_uniq_id" or "n"
- ignorelatlon
 set to TRUE to skip the slowest step of inferring ST from latlon in case you want to do that via sites2blocks info on blocks nearby
Value
the input table as a data.frame, but with these new columns if ST was not already a column: ejam_uniq_id, ST, statename, FIPS.ST, REGION, n
Examples
  state_from_sitetable(testpoints_10)
#>         lat        lon sitenumber        sitename ejam_uniq_id ST
#> 1  37.64122 -122.41065          1  Example Site 1            1 CA
#> 2  43.92249  -72.66370          2  Example Site 2            2 VT
#> 3  40.69351  -73.98002          3  Example Site 3            3 NY
#> 4  45.29520  -92.98184          4  Example Site 4            4 MN
#> 5  39.43730  -74.72370          5  Example Site 5            5 NJ
#> 6  45.67487  -94.81534          6  Example Site 6            6 MN
#> 7  33.14865 -117.19895          7  Example Site 7            7 CA
#> 8  34.01176  -80.95414          8  Example Site 8            8 SC
#> 9  43.01026  -89.45952          9  Example Site 9            9 WI
#> 10 40.74625  -74.25955         10 Example Site 10           10 NJ
#>         statename FIPS.ST REGION  n
#> 1      California      06      9  1
#> 2         Vermont      50      1  2
#> 3        New York      36      2  3
#> 4       Minnesota      27      5  4
#> 5      New Jersey      34      2  5
#> 6       Minnesota      27      5  6
#> 7      California      06      9  7
#> 8  South Carolina      45      4  8
#> 9       Wisconsin      55      5  9
#> 10     New Jersey      34      2 10
  state_from_sitetable(testoutput_ejamit_10pts_1miles$results_bysite[, .(ejam_uniq_id, ST, pop)])
#> Error in .(ejam_uniq_id, ST, pop): could not find function "."
  state_from_sitetable(testoutput_ejamit_10pts_1miles$results_bysite[, .(ST, pop)])
#> Error in .(ST, pop): could not find function "."
  state_from_sitetable(testoutput_ejamit_10pts_1miles$results_bysite[, .(ST, lat, lon, pop)])
#> Error in .(ST, lat, lon, pop): could not find function "."