The built-in function of data preparation for mapping and plotting. If you want to fetch the whole data, please prefer using get_data().
data_preparation(data, Year, Nutrient, County = NULL, State = NULL, Farm_Type = NULL, Input_Type = NULL, lat_max = NULL, lat_min = NULL, long_max = NULL, long_min = NULL, FIPSs = NULL, overlap_state_county = TRUE, combine_state_county = FALSE, fun = NULL, annual_change = NULL, facet = NULL, level = "county", na.rm = TRUE, ...)
data | the dataset to plot. default: us_fertilizer_county. |
---|---|
Year | the temporal coverage of the data to visualize. See link for available period. |
Nutrient | the nutrient type of fertilizer from usfertilizer. Has to be N, P or both (NULL). |
County | the counties that will show in the plot, default: all counties. |
State | the states that will show in the plot,default: all states. |
Farm_Type | the spatial source of fertilizer, should be farm, nonfarm or both. |
Input_Type | the input source of fertilizer, should be manure, fertilizer. |
lat_max | the maximum latitude of area of interest. |
lat_min | the minmum latitude of area of interest. |
long_max | the maximum longitude of area of interest. |
long_min | the minimum longitude of area of interest. |
FIPSs | FIPS numbers of interest, defalut: all the counties. |
overlap_state_county | Logic. If true, the function will overlaping the input of states and counties. If false, the function will return results either in the states or in the counties. |
combine_state_county | Logic. If true, the county will be changed into county, state, e.g. Wake, NC; If false, no changes. |
fun | the function to process data, not done yet. |
annual_change | to check if the data represent the annual change, default: FALSE. |
facet | the facet to draw subplots. |
level | the spatial resolution of map, should be county or state, default county. |
na.rm | How to deal with NA values. Default: TRUE. |
... | extra parameters for |
A tibble with tidy data.
link(data_overview), link(get_FIPS), link(get_data)
require(ggfertilizer) require(usfertilizer) data("us_fertilizer_county") plot_data = data_preparation(data = us_fertilizer_county, Year = 2003, Nutrient = "N") head(plot_data)#> # A tibble: 6 x 12 #> FIPS State County ALAND AWATER INTPTLAT INTPTLONG Quantity Year Nutrient #> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <chr> #> 1 01001 AL Autauga 1.54e9 2.58e7 32.5 -86.6 739534 2003 N #> 2 01003 AL Baldwin 4.12e9 1.13e9 30.7 -87.7 4604221 2003 N #> 3 01005 AL Barbour 2.29e9 5.09e7 31.9 -85.4 3831765 2003 N #> 4 01007 AL Bibb 1.61e9 9.29e6 33.0 -87.1 154170 2003 N #> 5 01009 AL Blount 1.67e9 1.52e7 34.0 -86.6 1289567 2003 N #> 6 01011 AL Bullock 1.61e9 6.06e6 32.1 -85.7 507476 2003 N #> # ... with 2 more variables: Farm.Type <chr>, Input.Type <chr>