View source: R/Datetime2Time.R
Datetime2Time | R Documentation |
Convert Datetime columns to Time columns
Datetime2Time(
dataset,
cols = dplyr::where(lubridate::is.POSIXct),
silent = FALSE
)
dataset |
A data.frame with POSIXct columns. |
cols |
The column names to convert. Expects a |
silent |
Logical on whether no message shall be shown if input and
output are identical. Defaults to |
The input dataset with converted POSIXct columns as time (hms) columns. With the default settings, if no POSIXct column exists, input and output will be identical.
sample.data.environment |> Datetime2Time()
#more than one POSIX col
sample.data.environment |>
dplyr::mutate(Datetime2 = lubridate::POSIXct(1)) |>
Datetime2Time()
#only converting one of them
sample.data.environment |>
dplyr::mutate(Datetime2 = lubridate::POSIXct(1)) |>
Datetime2Time(Datetime)
#if uncertain whether column exists
sample.data.environment |>
Datetime2Time(dplyr::any_of("Datetime3"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.