knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(reflow) options(reflow.quiet = FALSE) rs <- rules( "function header opening paren should not be preceded by whitespace" = rule( "function", ws(0), "expr" ), "function header closing paren should have a single space before an opening curly brace" = rule( on = list("function", "expr", pexpr("{")), "function", "expr", ws(1), pexpr("{") ), "multiline function headers should leave an empty line before the function body" = rule( on = list("function", multiline("expr"), pexpr("{")), "function", multiline("expr"), pexpr("{", ws(nl=2)) ), "parameter assignments should always be surrounded by single spaces" = rule( on = "eq_formals", ws(1), "=", ws(1) ), "multiline expressions should be indented by one level" = rule( "{", ws(nl = 1), indent(zero_or_more(any_token(), until = "}")), ws(nl = 1), "}" ) ) match_style(rs, " test <- function() 1L test <- function (a = 1L, b = 3){ 1 + 2L { 1 + 2 } } ")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.