https://github.com/GegznaV/snippets
:heavy_check_mark: (R package) Manage RStudio snippets
https://github.com/GegznaV/snippets
r rstudio snippets
Last synced: 4 months ago
JSON representation
:heavy_check_mark: (R package) Manage RStudio snippets
- Host: GitHub
- URL: https://github.com/GegznaV/snippets
- Owner: GegznaV
- License: other
- Created: 2020-01-04T19:55:11.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-07-31T20:43:40.000Z (9 months ago)
- Last Synced: 2024-08-01T00:20:24.329Z (9 months ago)
- Topics: r, rstudio, snippets
- Language: Vim Snippet
- Homepage: https://gegznav.github.io/snippets/
- Size: 579 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - GegznaV/snippets - :heavy_check_mark: (R package) Manage RStudio snippets (Vim Snippet)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[](https://CRAN.R-project.org/package=snippets)
[`-brightgreen.svg)](https://github.com/GegznaV/snippets)
[](https://github.com/GegznaV/snippets/actions)
[](https://codecov.io/gh/GegznaV/snippets?branch=master)
[](https://www.tidyverse.org/lifecycle/#experimental)
[)`-yellowgreen.svg)]()# Package `snippets`
## Installation
To install package from CRAN-like repository:
```{r, eval=FALSE}
repos <- c("https://mokymai.github.io/download/", getOption("repos"))
install.packages("snippets", repos = repos)
```To install from [GitHub](https://github.com/):
```{r, eval=FALSE}
if (!require(remotes)) install.packages("remotes")
remotes::install_github("GegznaV/snippets")
```## Quickstart
### Install Snippets from "snippets"
```{r eval=FALSE}
# Replace current files with snippets with those in package "snippets"
# (backup copies are created by default)
snippets::install_snippets_from_package("snippets")
``````{r, include=FALSE, eval=FALSE}
# Replace current R and Markdown snippets with those in package "snippets"
snippets::install_snippets_from_package("snippets", type = c("r", "markdown"), backup = TRUE)
```### More Examples
```{r eval=FALSE}
library(snippets)
``````{r eval=FALSE}
# Get the name of the directory where RStudio snippets are stored
get_path_rstudio_snippets_dir()
``````{r eval=FALSE}
# Open the directory with RStudio snippets
open_rstudio_snippets_dir()
``````{r eval=FALSE}
# Replace your R and Markdown snippets with those in package "snippets"
install_snippets_from_package("snippets", type = c("r", "markdown"), backup = TRUE)
list_snippet_file_backups()
``````{r eval=FALSE}
# View and edit file with snippets of certain type: r
open_rstudio_snippets_file(type = "r")
``````{r eval=FALSE}
# View and edit file with snippets of certain type: markdown
open_rstudio_snippets_file(type = "markdown")
```### Create and Clean-up Back-ups
```{r eval=FALSE}
# Create several back up files
backup_rstudio_snippets(type = "r")
Sys.sleep(1)
backup_rstudio_snippets(type = "r")
Sys.sleep(1)
backup_rstudio_snippets(type = "r")
``````{r eval=FALSE}
list_snippet_file_backups(type = "r")
``````{r eval=FALSE}
# Remove duplicated back-up files
remove_snippet_backup_duplicates()
```# Additional resources
## More on using and writing RStudio snippets
1. [Code Snippets](https://support.rstudio.com/hc/en-us/articles/204463668-Code-Snippets)
(on RStudio website).
All information is relevant to RStudio users.
2. [R tip: Save time with RStudio code snippets](https://www.youtube.com/watch?v=h_i__VTSurU)
(Case study on YouTube).
3. [Snippets](https://cloud9-sdk.readme.io/docs/snippets) (on Cloud9 SDK website).
Advanced topics on writing snippets.
Most sections (but not all) are relevant to RStudio users.## Similar projects
1. Package [**snippr**](https://github.com/dgrtwo/snippr).
## More snippets
1. [Snippets](https://github.com/dgrtwo/snippets) by @dgrtwo.
1. [Snippets](https://github.com/gadenbuie/snippets) by @gadenbuie.