f_12_hour {numform} | R Documentation |
Format 12 Hour Times
Description
Format times to the typical 12 hour '
Usage
f_12_hour(x = Sys.time(), format = "%I:%M %p", pad.char = "", ...)
## Default S3 method:
f_12_hour(x, format = "%I:%M %p", pad.char = "", ...)
## S3 method for class 'integer'
f_12_hour(x, format = "%I:%M %p", pad.char = "", ...)
## S3 method for class 'numeric'
f_12_hour(x, format = "%I:%M %p", pad.char = "", ...)
## S3 method for class 'hms'
f_12_hour(x, format = "%I:%M %p", pad.char = "", ...)
ff_12_hour(format = "%I:%M %p", pad.char = "", ...)
Arguments
x |
A vector of coercible times. |
format |
A character string specifying the time output format. |
pad.char |
A character to use for leading padding if lengths of output are unequal. |
... |
Other arguments passed to |
Value
Returns a string of publication ready 12 hour time stamps.
Examples
f_12_hour(Sys.time())
f_12_hour(Sys.time(), pad.char ='0')
f_12_hour(Sys.time(), pad.char =' ')
f_12_hour(Sys.time(), '%I:%M:%S %p')
f_12_hour(c(NA, 0:24), '%I %p')
set.seed(10)
times <- as.POSIXct(sample(seq_len(1e4), 12), origin = '1970-01-01')
paste(f_12_hour(range(times)), collapse = ' to ')
## Not run:
library(tidyverse)
set.seed(10)
data_frame(
time = as.POSIXct(sample(seq_len(1e4), 12), origin = '1970-01-01'),
val = sample(1:20, length(time), TRUE)
) %>%
mutate(prop = val/sum(val)) %>%
ggplot(aes(time, prop)) +
geom_line() +
scale_x_time(labels = ff_12_hour(format = '%I %p')) +
scale_y_continuous(labels = ff_prop2percent(digits = 0))
## End(Not run)
[Package numform version 0.7.0 Index]