Skip to content

Instantly share code, notes, and snippets.

@Andrei-WongE
Created March 22, 2024 19:57
Show Gist options
  • Save Andrei-WongE/6c654634c4ebe101dfd1d5f31a50da47 to your computer and use it in GitHub Desktop.
Save Andrei-WongE/6c654634c4ebe101dfd1d5f31a50da47 to your computer and use it in GitHub Desktop.
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