Returns a list with data on weather and stations for a selected county.
This function serves as a wrapper to several functions from the
package, which pull weather data from all relevant stations in a county.
This function filters and averages data returned by
across all weather stations in a county based on user-specified
A dataframe containing station metadata, returned from
A numeric value in the range of 0 to 1 that specifies
the desired percentage coverage for the weather variable (i.e., what
percent of each weather variable must be non-missing to include data from
a monitor when calculating daily values averaged across monitors. The
default is to include all monitors with any available data (i.e.,
A character vector specifying desired weather variables. For
A string with the desired starting date in character, ISO format ("yyyy-mm-dd"). The dataframe returned will include only stations that have data for dates including and after the specified date.
A string with the desired ending date in character, ISO format ("yyyy-mm-dd"). The dataframe returned will include only stations that have data for dates up to and including the specified date.
TRUE / FALSE to indicate if you want the function to average daily weather data across multiple monitors. If you choose FALSE, the function will return a dataframe with separate entries for each monitor, while TRUE (the default) outputs a single estimate for each day in the dataset, giving the average value of the weather metric across all available monitors in the county that day.
A list with two elements.
daily_data is a dataframe of daily
weather data averaged across multiple monitors and includes columns
"var"_reporting) for each weather variable showing the number of
stations contributing to the average for that variable on that day.
station_df is a dataframe of station metadata for each
station contributing weather data. A weather station will have one row per
weather variable to which it contributes data. In addition to information
such as station id, name, latitude, and longitude, the
dataframe includes statistical information about weather values
contributed by each station for each weather variable. These statistics
calc_coverage (the percent of non-missing values for each
station-weather variable combination for the specified date range),
standard_dev (standard deviation),
(giving the minimum and maximum values), and
range, giving the
range of values in each station-weather variable combination. The
radius is the calculated radius within which stations were
pulled from the county's center. Elements
lon_center are the latitude and longitude of the county's center.
Because this function uses the NOAA API to identify the weather
monitors within a U.S. county, you will need to get an access token from
NOAA to use this function. Visit NOAA's token request page
(http://www.ncdc.noaa.gov/cdo-web/token) to request a token by
email. You then need to set that API code in your R session (e.g., using
options(noaakey = "your key"), replacing "your key" with the API
key you've requested from NOAA). See the package vignette for more details.
1 2 3 4 5 6 7 8 9 10 11 12
## Not run: stations <- daily_stations(fips = "12086", date_min = "2010-01-01", date_max = "2010-02-01") fips_list <- daily_df(stations = stations, coverage = 0.90, var = c("tmax", "tmin", "prcp"), date_min = "2010-01-01", date_max = "2010-02-01") averaged_data <- fips_list$daily_data head(averaged_data) station_info <- fips_list$station_df head(station_info) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.