Description Usage Arguments Functions Using the grkmisc code style Examples
Use styler::style_text()
to format code according to the unofficial
grkmisc style guide.
1 2 3 4 5 6 7 8 9 10 11 | use_grk_style()
grk_style_transformer(...)
grk_style_text(text, ...)
grk_style_file(path, ...)
grk_style_dir(path, ...)
grk_style_pkg(pkg, ...)
|
... |
Arguments passed to underling styler functions (identified
by removing the |
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. |
use_grk_style
: Set the grkmisc style as the default style for
styler addins.
grk_style_transformer
: A code transformer for use with styler::style_text()
grk_style_text
: Style text using the grkmisc code style
grk_style_file
: Style a file using the grkmisc code style
grk_style_dir
: Style a directory using the grkmisc code style
grk_style_pkg
: Style a package 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()")
|
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.