Description Usage Arguments Value Note Examples
Given a vector of U.S. county FIPS codes, this function saves each element of
the lists created from the function daily_fips
to a separate folder
within a given directory. The dataframe daily_data
is saved to a
subdirectory of the given directory called "data." This time series dataframe
gives the values for specified weather variables and the number of
weather stations contributing to the average for each day within the
specified year(s). Metadata about the weather stations and
county are saved in a list with four elements in a subdirectory called
"metadata." These elements include station_metadata
(station metadata
for stations contributing to the time series dataframe), radius
(the radius, in km, within which weather stations were pulled from each
county's center), lat_center
, and lon_center
(the latitude
and longitude of the county's geographic center). If the user specifies "csv"
output for the metadata_type
argument, radius
, lat_center
,
and lon_center
are added to the station_metadata
dataframe as
three additional columns.
1 2 3 4 |
fips |
A character string of the five-digit U.S. FIPS code of a U.S. county. |
year |
A four-digit number or vector of numbers indicating the year or
years for which you want to pull hourly data. Values for |
coverage |
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). |
var |
A character vector specifying desired weather variables. For
example, |
out_directory |
The absolute or relative pathname for the directory where you would like the time series files to be saved. |
data_type |
A character string indicating that you would like either
.rds files ( |
metadata_type |
A character string indicating that you would like either
.rds files ( |
average_data |
TRUE / FALSE to indicate if you want the function to average daily weather data across multiple monitors. |
station_label |
TRUE / FALSE to indicate whether to include station labels in the station map. |
keep_map |
TRUE / FALSE indicating if a map of the stations should be included. The map can substantially increase the size of the files. If FALSE, the "maps" subdirectory will not be created. |
verbose |
TRUE / FALSE to indicate if you want the function to print out the county or vector of counties it's saving files for. |
Writes out three subdirectories of a given directory, with hourly
weather files saved in "data", station and county metadata saved in
"metadata", and a map of weather station locations saved in "maps" for each
FIPS code specified. The user can specify either .rds or .csv files for the
data and metadatafiles, using the arguments data_type
and
metadata_type
, respectively. Maps are saved as .png files.
If the function is unable to pull weather data for a particular county
given the specified percent coverage, date range, and/or weather variables,
write_hourly_timeseries
will not produce a file for that county.
1 2 3 4 5 6 | ## Not run:
write_hourly_timeseries(fips = c("08031", "12086"), year = c(1994, 1995),
coverage = 0.90, var = c("wind_speed", "temperature"),
out_directory = "~/timeseries_hourly")
## End(Not run)
|
Saving daily weather files for FIPS codes 08031 and 12086 in the directory ~/timeseries_hourly. This may take a while.
Unable to pull weather data for FIPS code 08031 for the specified percent coverage, year(s), and/or weather variables.
Unable to pull weather data for FIPS code 12086 for the specified percent coverage, year(s), and/or weather variables.
Warning messages:
1: In dir.create(out_directory) :
cannot create dir '/home/anon/timeseries_hourly', reason 'No such file or directory'
2: In dir.create(paste0(out_directory, "/data")) :
cannot create dir '/home/anon/timeseries_hourly/data', reason 'No such file or directory'
3: In dir.create(paste0(out_directory, "/metadata")) :
cannot create dir '/home/anon/timeseries_hourly/metadata', reason 'No such file or directory'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.