Tools for Building R Formats

Builds format strings that can be used with strptime() and sprintf().


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 ")
```
``` r
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")

News

easyformatr 1.0.0

  • Released

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("easyformatr")

0.1.2 by Brandon Taylor, a year ago


https://github.com/bramtayl/easyformatr


Report a bug at https://github.com/bramtayl/easyformatr/issues


Browse source code at https://github.com/cran/easyformatr


Authors: Brandon Taylor [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports dplyr, lazyeval, magrittr, stringi, tidyr, knitr, tibble

Suggests testthat, rmarkdown


See at CRAN