df_col_dt_format {oaii}R Documentation

Replace unix timestamp column(s) to formated dt string

Description

Replace unix timestamp column(s) to formated dt string

Usage

df_col_dt_format(
  df,
  col,
  format = "%Y-%m-%d %H:%M:%S",
  tz = "",
  on_missing_col = "warn"
)

Arguments

df

data.frame, input data.frame

col

character vector, column names of the df that will be modified

format

A character string. The default for the format methods is "%Y-%m-%d %H:%M:%S" if any element has a time component which is not midnight, and "%Y-%m-%d" otherwise. If options("digits.secs") is set, up to the specified number of digits will be printed for seconds.

tz

A character string specifying the time zone to be used for the conversion. System-specific (see as.POSIXlt), but "" is the current time zone, and "GMT" is UTC. Invalid values are most commonly treated as UTC, on some platforms with a warning.

on_missing_col

string, behavior for missing column(s): "warn" - log warning, "skip" - skip missing column(s), "stop" - throw error

Value

Modified input data.frame

Examples

df <- data.frame(
  x = c("a", "b"),
  dt = c(1687868601, 1688417643)
)
df_col_dt_format(df, "dt")
df_col_dt_format(df, "dt", "%H:%M")


[Package oaii version 0.5.0 Index]