Search code examples
rdataframedplyrr-markdownformatr

usage function from formatR removes white space unexpectedly


The usage function from removes white space unexpectedly. See the example below:

library(formatR)
library(tidyverse)
usage(
    FUN           = inner_join
  , width         = getOption("width")
  , tidy          = c(TRUE, FALSE)[1]
  , output        = c(TRUE, FALSE)[1]
  , indent.by.FUN = c(TRUE, FALSE)[2]
  , fail          = c("warn", "stop", "none")
)

inner_join(x, y, by = NULL, copy = FALSE, suffix = c(".x", ".y"), ..., keep = FALSE)

However, I want something like this:

inner_join(
  x,
  y,
  by = NULL,
  copy = FALSE,
  suffix = c(".x", ".y"),
  ...,
  keep = FALSE
)

Solution

  • Trial and error with width will get you close to what you want:

    usage(
      FUN           = inner_join
      , width         = 12
      , tidy          = TRUE
      , output        = TRUE
      , indent.by.FUN = TRUE
      , fail          = "none"
    )
    
    #> inner_join(
    #>            x,
    #>            y,
    #>            by = NULL,
    #>            copy = FALSE,
    #>            suffix = c(".x", ".y"),
    #>            ...,
    #>            keep = FALSE)