grk_style: The grkmisc Code Style

Description Usage Arguments Functions Using the grkmisc code style Examples

Description

Use styler::style_text() to format code according to the unofficial grkmisc style guide.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11

Arguments

...

Arguments passed to underling styler functions (identified by removing the grk_ prefix), except for transofrmers, which is set to the grk_style_transformer() internally.

text

A character vector with text to style.

path

A character vector with paths to files to style.

pkg

Path to a (subdirectory of an) R package.

Functions

Using the grkmisc code style

You can set the grkmisc code style as the default code style for styler (and its associated RStudio addins, like "Style active file" and "Style selection") by calling grkmisc::use_grk_style(). If you would rather set this option globally for all session, you can add the following to your .Rprofile:

1
options(styler.addins_style_transformer = "grkmisc::grk_style_transformer()")

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
use_grk_style()
# Use styler addins
styler:::style_selection()

## End(Not run)

ex_code <- "mtcars %>% mutate(mpg = mpg * 2,\n\t\t     cyl = paste(cyl)) %>% head()"
cat(ex_code)

grk_style_text(ex_code)

GerkeLab/grkmisc documentation built on Feb. 23, 2020, 6:50 a.m.