README.md

Travis-CI Build Status codecov.io

Friendly Time Formats

Have you ever had to build a way too complicated time format?

my_time_format = "%Ey/%b/%0d%t%0I:%0M:%0S3 %p %Z"

How about a too complicated string format?

my_string_format = "%1$+03.0f and 1%% and %1$-+3.0f"

No human could read this. easyformatr allows you to build understandable R format strings.

library(easyformatr)
library(magrittr)
easy_format(list(double %>% 
                     zero_pad,
                   "1%",
                   double %>% 
                     left_justify) %>%
                use_input(1) %>%
                always_sign %>%
                before_decimal(3) %>%
                after_decimal(0),
              sep = " and ")
## %1$+03.0f and 1%% and %1$-+3.0f
easy_format(list(year %>% religious, 
                 "/", 
                 month %>% name) %>%
              short,
            "/", 
            list(day,
                 tab,
                 hour %>% twelve,
                 ":",
                 minute) %>%
              roman,
            ":",
            second %>% digits(3),

            " ",
            am_pm,
            " ",
            timezone)
## %Ey/%b/%0d%t%0I:%0M:%0S3 %p %Z

Inspired by kevinushey/rex

Installation

# for cran version
install.packages("easyformatr")

# for bleeding edge:
devtools::install_github("easyformatr")


Try the easyformatr package in your browser

Any scripts or data that you put into this service are public.

easyformatr documentation built on May 29, 2017, 11:57 a.m.