Skip to content

Instantly share code, notes, and snippets.

View charliejhadley's full-sized avatar
🙋‍♀️
All tech is political

Charlie Joey Hadley charliejhadley

🙋‍♀️
All tech is political
View GitHub Profile
@charliejhadley
charliejhadley / tidyeval-names-glue.R
Created September 21, 2022 11:53
tidyeval-names-glue.R
library(tidyverse)
fn_with_tidyeval_glue <- function(.data, target_column){
chr_target_column <- quo_name(enquo(target_column))
pvw_glue <- paste0("{", chr_target_column, "}_{.value}")
.data %>%
pivot_wider(
@charliejhadley
charliejhadley / quarto-reveal-delimit.qmd
Created September 20, 2022 11:46
quarto-reveal-delimit.qmd
---
title: "Untitled"
format: revealjs
---
First without heading
# First 1 heading
content
@charliejhadley
charliejhadley / lecture-styles.scss
Created September 7, 2022 13:32
xaringan -> quarto
/*-- scss:defaults --*/
$inverse-background-color: #272822;
$presentation-font-size-root: 28px;
$presentation-heading-color: #e10020;
$heading2Size: 55px;
$heading3Size: 45px;
$heading4Size: 35px;
$link-color: #e10020;
# from tibble::as_tibble() focs
tibble::as_tibble_col(
list(c = "three", d = list(4:5)),
column_name = "data"
)
#> # A tibble: 2 × 1
#> data
#> <named list>
#> 1 <chr [1]>
#> 2 <list [1]>
@charliejhadley
charliejhadley / processing-json-like-data.R
Created July 21, 2022 13:16
processing-json-like-data.R
library(tidyverse)
some_data <- tibble(
messy_col = c('{"id":"1234567","bio":"John Smith, first-year undergraduate in Physics","username":"JSAstronaut"}',
'{"id":"00303","bio":"Jo Smith, first-year undergraduate in Physics","username":"JSAstronaut"}')
)
some_data$messy_col %>% fromJSON()
# Target each column at once:
@charliejhadley
charliejhadley / synthetic-aesthetic.R
Last active July 9, 2022 06:45
synthetic-aesthetic.R
library(tidyverse)
library(rnaturalearthdata)
library(sf)
country_sf <- countries110 %>%
st_as_sf()
ggplot() +
geom_sf(data = country_sf,
aes(fill = lastcensus,
@charliejhadley
charliejhadley / quarto.qmd
Created June 20, 2022 19:19
difference between quarto and rmarkdown
---
title: "{quarto}"
format: html
---
````{verbatim}
---
output: html_document
---
@charliejhadley
charliejhadley / force-not-eval.Rmd
Created June 20, 2022 17:07
force-not-eval.Rmd
---
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_hooks$set(force_not_eval = function(value) {
value$eval <- FALSE
value
}
)
@charliejhadley
charliejhadley / yaml-indentation.Rmd
Created June 9, 2022 11:52
yaml-indentation.Rmd
---
title: "Report"
output:
word_document:
reference_docx: template.docx
html_document:
toc: TRUE
toc_depth: 2
toc_float: TRUE
---
@charliejhadley
charliejhadley / yaml-indentation.Rmd
Created June 9, 2022 11:50
yaml-indentation.Rmd
---
title: "Untitled"
output:
html_document:
toc: TRUE
toc_depth: 2
toc_float: TRUE
---