Description Usage Arguments Value Examples
This function inputs a dataframe of observations for US counties that includes a column with date-time expressed in Coordinated Universal Time (UTC), as well as a single value or vector of FIPS code(s) for the county associated with each observation. It will return the original dataframe with columns added for local date-time, local date, and, if specified, local time zone.
1 | add_local_time(df, fips, datetime_colname, include_tz = TRUE)
|
df |
A dataframe of observations that includes a column with a
date-time object in Coordinated Universal Time (UTC) (see the documentation
for the |
fips |
A character vector giving the 5-digit FIPS code of the county
associated with each observation. This can be either a string of length 1,
if all observations come from the same county, or a vector as long as the
|
datetime_colname |
A character string giving the column name for the column that gives date-time in UTC in the input dataframe. |
include_tz |
A TRUE / FALSE value specifying whether to include a
column with the local time zone ( |
This function returns the dataframe input to the function, with columns added with local date-time, local date, and, if specified, local time zone.
1 2 3 4 5 6 7 8 9 | ex_df <- data.frame(datetime = c("1999-01-01 08:00", "1999-01-01 09:00",
"1999-01-01 10:00"),
fips = c("36061", "17031", "06037"))
add_local_time(df = ex_df, fips = ex_df$fips,
datetime_colname = "datetime")
ex_df <- data.frame(datetime = c("1999-01-01 08:00", "1999-01-01 09:00",
"1999-01-01 10:00"))
add_local_time(df = ex_df, fips = "36061", datetime_colname = "datetime")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.