Given a particular county FIPS code, this function returns data and meta-data for weather data, either for all available dates or for dates within a requested date range.
1 2 3
A string with the five-digit U.S. FIPS code of a county in numeric, character, or factor format.
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 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.
A character vector specifying desired weather variables. For
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.
TRUE / FALSE to indicate if you want your plot of weather station locations to include labels with station ids.
TRUE / FALSE to indicate if you want the function to print out the name of the county it's processing.
A list with three elements. The first element (
daily_data) is a
dataframe of daily weather data averaged across multiple stations, as well
as columns (
"var"_reporting) for each weather variable showing the
number of stations contributing to the average for that variable on that
day. The second element (
station_metadata) is a dataframe of station
metadata for stations included in the
daily_data dataframe, as well
as statistical information about these values. Columns
range. The third element (
is a plot showing locations of all weather stations for a particular county
satisfying the conditions present in
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 13 14 15
## Not run: denver_ex <- daily_fips("08031", coverage = 0.90, date_min = "2010-01-01", date_max = "2010-02-01", var = "prcp") head(denver_ex$daily_data) denver_ex$station_map mobile_ex <- daily_fips("01097", date_min = "1997-07-13", date_max = "1997-07-25", var = "prcp", average_data = FALSE) library(ggplot2) ggplot(mobile_ex$daily_data, aes(x = date, y = prcp, color = id)) + geom_line() ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.