Created
March 22, 2024 19:57
-
-
Save Andrei-WongE/6c654634c4ebe101dfd1d5f31a50da47 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet fragment | |
[${1:text}]{.${2:type}} | |
snippet aside | |
[${1:text}]{.aside} | |
snippet fence | |
:::{.${1:type}} | |
${2:body} | |
::: | |
snippet panel | |
::: {.panel-tabset} | |
${1:body} | |
::: | |
snippet column | |
:::: {.columns} | |
::: {.column width="50%"} | |
Left column | |
::: | |
::: {.column width="50%"} | |
Right column | |
::: | |
:::: | |
snippet header | |
## --------------------------- | |
## | |
## Script name: ${1} | |
## | |
## Project:${2} | |
## | |
## Purpose of script: ${3} | |
## | |
## Author: Andrei Wong Espejo | |
## | |
## Date Created: `r paste(Sys.Date())` | |
## | |
## Email: [email protected] | |
## | |
## --------------------------- | |
## | |
## Notes: ${4} | |
## | |
## | |
## --------------------------- | |
## Program Set-up ------------ | |
options(scipen = 100, digits = 4) # Prefer non-scientific notation | |
## Load required packages ---- | |
if (!require("pacman")) { | |
install.packages("pacman") | |
} | |
pacman::p_load(here, datapasta, dplyr, readr, janitor, tidyverse) | |
## Runs the following -------- | |
snippet create_filename | |
paste0(paste(format(Sys.Date(),"%Y"), format(Sys.Date(),"%m"), format(Sys.Date(),"%d"), sep = "_" ), ".csv") | |
snippet h2 | |
# ├ ${1} | |
snippet end | |
`r strrep(ifelse(substr("$$", 1, 1) %in% c("-", "="), substr("$$", 1, 1), "#"), 84 - rstudioapi::primary_selection(rstudioapi::getActiveDocumentContext())$range$start[2])` | |
snippet endhead | |
`r paste0(rep.int("-", 88 - rstudioapi::primary_selection(rstudioapi::getActiveDocumentContext())$range$start[2]), collapse = "")` | |
snippet reproduci | |
<details><summary>Reproducibility receipt</summary> | |
```{r} | |
## Datetime | |
Sys.time() | |
## Repository | |
git2r::repository() | |
## session info | |
xfun::session_info() | |
``` | |
</details> | |
snippet show_ex | |
show_in_excel <- function(.data){ | |
tmp <- paste0(tempfile(), ".csv") | |
write.csv(.data, tmp) | |
#fs:: file_show(path = tmp) | |
browseURL(tmp) | |
} | |
show_in_excel($1) | |
snippet loadpack | |
if (!require("pacman")) { | |
install.packages("pacman") | |
} | |
pacman::p_load(tidyverse, tidylog, janitor, openxlsx, here, purrr, ${1}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment