| add.datetime | R Documentation |
A helper function to convert UTC datetime to local datetime.
add.datetime(df, type = 3, timezone, reverse = FALSE)
df |
a data frame. |
type |
an integer from 1 to 3. Use 1 to add datetime, 3 to add datetime, date, and time, and 2 to add date and time. |
timezone |
a character string, local time zone. |
reverse |
a logical, whether to convert local datetime to UTC datetime. |
a data frame with additional columns.
# example a
df <- data.frame(datetime.UTC = as.POSIXct(c("2025-01-01 01:00:00",
"2025-07-01 01:00:00"), tz = "UTC"))
df
df1 <- add.datetime(df, type = 1, timezone = "")
df1
df1$datetime.UTC
df1$datetime
df3 <- add.datetime(df, type = 3, timezone = "")
df3
# example b
data <- data.frame(datetime = as.POSIXct(c("2025-02-01 01:00:00", "2025-08-01 01:00:00")))
data$datetime
data2 <- add.datetime(data, type = 2)
data2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.