Skip to content

gadenbuie/snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snippets for RStudio

Various custom snippets designed for RStudio, but possibly useful elsewhere.

Copy the snippets into the correct language file from the Global Options > Code > Edit Snippets menu.

Or use dgrtwo/snippr to install:

# remotes::install_github("dgrtwo/snippr")
library(snippr)

# For all snippets
snippets_install_github("gadenbuie/snippets")

# For just the R snippets
snippets_install_github("gadenbuie/snippets", language = "r")

# For just an individual snippet
snippets_install_github("gadenbuie/snippets", language = "r", name = "aa")

For manual installation, copy the snippets to ~/.R/snippets/r.snippets or ~/.config/rstudio/snippets for RStudio 1.3. (Windows uses a different directory that I don't know off the top of my head, sorry.). usethis::edit_rstudio_snippets() may provide better advice.

local({
  snippets_dir <- fs::path_home(".config", "rstudio", "snippets")
  fs::dir_create(snippets_dir) # make sure ~/.R/snippets exists

  gh_base_url <- "https://raw.githubusercontent.com/gadenbuie/snippets/main/"

  for (snippet in paste0(c("r", "markdown", "css", "html"), ".snippets")) {
    download.file(
      paste0(gh_base_url, snippet),
      fs::path(snippets_dir, snippet)
    )
  }
})

You may be able to find other useful snippets using this GitHub search.

About

My snippets for RStudio (or elsewhere)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published