Learn R Programming

messy (version 0.1.0)

messy_datetime_tzones: Change the timezone of datetime columns

Description

Takes any number of datetime columns and changes their timezones either totally at random, or from a user-provided list of timezones.

Usage

messy_datetime_tzones(data, cols = NULL, tzones = OlsonNames(), force = FALSE)

Value

a dataframe the same size as the input data.

Arguments

data

input dataframe

cols

set of columns to apply transformation to. If NULL will apply to all POSIXt columns.

tzones

Valid time zones to sample from. By default samples from all OlsonNames(), but can be set to options more relevant to the data.

force

By default (force = FALSE) the datetimes will have their actual hour/minute values changed along with the timezones. If force = TRUE, which requires lubridate, the datetime values will remain the same and only the timezone will differ.

Author

Jack Davison

See Also

Other Messy date(time) functions: messy_datetime_formats(), split_datetimes()

Examples

Run this code
data <- data.frame(dates = rep(Sys.time(), 10))

data$dates
attr(data$dates, "tzone")

messy <- messy_datetime_tzones(data, tzones = "Poland")
messy$dates
attr(messy$dates, "tzone")

Run the code above in your browser using DataLab