Replace code in .R scripts. Be sure to use version control as wrong patterns
might result in unintended replacements. Note that you should specify the
pattern by stingr::regex(pattern, dotall = TRUE)
to also match line
terminators (all lines of a script are pasted into a single string).
1 2 | replace_code(file, pattern, replacement,
ending = ".*[.](r|R|s|S|q)([.](lnk|LNK))*$", all = FALSE)
|
file |
A path to an .R script or a directory containing .R scripts. |
pattern |
Pattern to look for. The default interpretation is a regular expression, as described
in stringi::stringi-search-regex. Control options with
Match a fixed string (i.e. by comparing only bytes), using
|
replacement |
A character vector of replacements. Should be either
length one, or the same length as To perform multiple replacements in each element of To replace the complete string with |
all |
If |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.