Replace current file with snippets with the other file.

install_snippets_from_package(
  package,
  type = "auto-detect-all",
  subdir = "",
  backup = TRUE
)

install_snippets_from_dir(
  from_dir = ".",
  type = get_default_snippet_types(),
  backup = TRUE
)

Arguments

package

(character) The name of an R package.

type

(character) A character vector of snippet types. Currently allowed values are "r", "markdown", "c_cpp", "css", "html", "java", "javascript", "python", "sql", "stan", "tex". May be unambiguously truncated. Defaults to "r".

subdir

(character) The sub-directory with replacement file(s).

backup

(logical) Indication if a back-up copy should be created.

from_dir

(character) The directory with replacement file.

Examples

if (FALSE) {

  # Replace your R and Markdown snippets with those in package "snippets":
  install_snippets_from_package("snippets")
  install_snippets_from_package("snippets", type = "r")
  install_snippets_from_package("snippets", type = "markdown")

  # Check if back-up copies exist:
  list_snippet_file_backups(type = "r")
  list_snippet_file_backups(type = "markdown")

  remove_snippet_backup_duplicates()
}