-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,618 additions
and
617 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
_freeze/posts/2024-05-08-aesthetic/index/execute-results/html.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"hash": "3b839e1aa005930371e489fd1130e796", | ||
"result": { | ||
"markdown": "---\ntitle: \"The Aesthetics Wiki: an R Addendum\"\ndate: 2024-05-08\nslug: \"aesthetic\"\ncategories:\n - base\n - r\n - tidyverse\n---\n\n\n![They're doing the Lord's work over at [makewordart.com](https://www.makewordart.com/).](resources/passion.png){fig.alt=\"90s-style Word Art saying 'aesethics' in the middle, surrounded by the words 'base R', 'tidyverse' and 'tidy base question' in various egregious fonts and colours.\" width='100%'}\n\n## tl;dr\n\nSome people look at an R script and see code. But I _feel_ something.\n\n## A philosophy\n\nHave you experienced the [Aesthetics Wiki](https://aesthetics.fandom.com/wiki/Aesthetics_Wiki)?\n\nIt's missing R-related entries for some reason, which definitely fit [the aesthetic philosophy](https://aesthetics.fandom.com/wiki/Philosophy) of having:\n\n> perspectives on beauty and the human condition and a political, economic, or social statement\n\nTell me you don't look at an R script and get an immediate vibe.\n\nI want to suggest two obvious aesthetics for submission to the wiki—_Basecore_ and _Tidywave_—and to introduce the definitely-soon-to-be-mainstreamed _V4 Punk_[^suffix].\n\n## The addendum\n\n### Basecore\n\n![Adapted from [Aesthetics Wiki](https://static.wikia.nocookie.net/aesthetics/images/1/15/Chaotic_academia.jpg/revision/latest?cb=20200610213320).](resources/chaotic-academia.png){fig.alt=\"A set of different-sized books haphazardly placed ona bookshelf.\" width='100%'}\n\n#### Overview\n\n* History: emerged as Base Academic in 1993, mainstreamed as Base Core from 2000 to date.\n* Visuals: `[` (square-bracket selector), `$` (dollar selector), `~` (formula-form tilde).\n* Palette: <span style=\"background-color:lightgrey;\">grey</span>.\n* Fashion: Emacs, mailing lists, a wired mouse with a ball in it.\n* Nearest aesthetic: [Chaotic Academia](https://aesthetics.fandom.com/wiki/Chaotic_Academia), which 'acknowledges the pretentiousness of classic academia, subtly mocking it at times'.\n\n#### Sample\n\nClassic stuff. Typical base-R code uses a lot of intermediate assignment to create temporary objects for further manipulation. Many actions make use of square bracket notation to indicate some action over rows and columns of a data.frame. Data.frame columns have to be called within the context of the data.frame they belong to, using dollar or square-bracket notation. The tilde is used for formula notation ('this given that').\n\n<details><summary>Set up demo data</summary>\n\n::: {.cell}\n\n```{.r .cell-code}\nsuppressPackageStartupMessages(library(dplyr))\nsw_a <- starwars[, c(\"name\", \"species\", \"height\")]\nsw_b <- starwars[, c(\"name\", \"homeworld\")]\n```\n:::\n\n</details>\n\n\n::: {.cell}\n\n```{.r .cell-code}\nx <- sw_a[sw_a$species == \"Human\", names(sw_a) != \"species\"]\nx <- merge(x, sw_b, by = \"name\")\nx$height <- x$height / 100\nx$homeworld <- ifelse(\n !x$homeworld %in% c(\"Tatooine\", \"Naboo\"),\n \"Other\",\n x$homeworld\n)\nx <- aggregate(x, height ~ homeworld, mean, na.rm = TRUE)\nx <- x[order(-x$height), ]\nx\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n homeworld height\n3 Tatooine 1.792500\n2 Other 1.776471\n1 Naboo 1.772000\n```\n:::\n:::\n\n\n### Tidywave\n\n![Adapted from [Aesthetics Wiki](https://static.wikia.nocookie.net/aesthetics/images/6/62/Blob-web-exercise.webp/revision/latest?cb=20210410215136).](resources/corporate-memphis.png){fig.alt=\"Colourful stylised cartoon of faceless humans with small heads and large limbs and hands.\" width='100%'}\n\n#### Overview\n\n* History: humble academic origins in 2008, later popularised with the creation of the {tidyverse} in 2016.\n* Visuals: `%>%` ({magrittr} pipe), `.` (data placeholder), `~` (lambda function).\n* Palette: Posit <span style=\"background-color:#1a162d;color:white;\">blue</span>, <span style=\"background-color:#fdeba4;\">yellow</span>, and <span style=\"background-color:#767381;color:white;\">grey</span>.\n* Fashion: RStudio, hex stickers, rapid deprecation.\n* Nearest aesthetic: [Corporate Memphis](https://aesthetics.fandom.com/wiki/Corporate_Memphis) because I've literally seen it in Posit marketing.\n\n#### Sample\n\nThe script reads from left-to-right and top-to-bottom, recipe style, using pipes: 'take dataset, then do a thing, then do a thing', etc. Each function is verb that indicates its action. Non-standard evaluation is rampant. A tilde replaces the tedious typing of <kbd>f</kbd><kbd>u</kbd><kbd>n</kbd><kbd>c</kbd><kbd>t</kbd><kbd>i</kbd><kbd>o</kbd><kbd>n</kbd><kbd>(</kbd><kbd>)</kbd>. A titchy inconspicuous `.` acts as a data placeholder on the right-hand side of a pipe.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsw_a %>%\n filter(species == \"Human\") %>%\n select(-species) %>%\n left_join(sw_b, by = \"name\") %>%\n mutate(\n height = height / 100,\n homeworld = if_else(\n !homeworld %in% c(\"Tatooine\", \"Naboo\"),\n \"Other\",\n homeworld\n )\n ) %>%\n summarise(\n height = mean(height, na.rm = TRUE),\n .by = homeworld\n ) %>%\n arrange(desc(height))\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n# A tibble: 3 × 2\n homeworld height\n <chr> <dbl>\n1 Tatooine 1.79\n2 Other 1.78\n3 Naboo 1.77\n```\n:::\n:::\n\n\n#### V4 Punk\n\n![Adapted from [Aesthetics Wiki](https://static.wikia.nocookie.net/aesthetics/images/d/d1/Magnum-pi-hawaiian-shirt.jpg/revision/latest?cb=20200507215616).](resources/vacation-dadcore.png){fig.alt=\"Tom Sellick in a Hawaiian shirt at the beach, leaning against a palm tree. He is smiling.\" width='100%'}\n\n#### Overview\n\n* History: incremental emergence following R version 4.0 in 2020, boosted greatly in 2022 with the release of the base pipe.\n* Visuals: `|>` (base pipe), `_` (data placeholder), `\\()` (lambda function).\n* Palette: <span style=\"background-color:#ff0000;\">r</span><span style=\"background-color:#ff00ff;\">a</span><span style=\"background-color:#00ffff;\">i</span><span style=\"background-color:#00ff00;\">n</span><span style=\"background-color:#0000ff;color:white;\">b</span><span style=\"background-color:#4b0082;color:white;\">o</span><span style=\"background-color:#ee82ee;\">w</span>?\n* Fashion: hubris, moustaches, troll-face emojis.\n* Nearest aesthetic: [Vacation Dadcore](https://aesthetics.fandom.com/wiki/Vacation_Dadcore), so you can 'escape to a simpler time without sacrificing any of the fun'.\n\n#### Sample\n\nHear me out: what if tidyverse, but made entirely of base R functions[^modern]? This is now possible with the base pipe and by using obscure functions that help you avoid square brackets[^poorman]. It's also sketchy as heck; just see the help files for `subset()` ('unanticipated consequences') and `transform()` ('you deserve whatever you get!'). The death of Basecore and Tidywave, for sure.\n\n\n::: {.cell}\n\n```{.r .cell-code}\nsw_a |>\n subset(\n species == \"Human\",\n select = -species\n ) |>\n merge(sw_b, by = \"name\") |>\n transform(\n height = height / 100,\n homeworld = ifelse(\n !homeworld %in% c(\"Tatooine\", \"Naboo\"),\n \"Other\",\n homeworld\n )\n ) |>\n aggregate(\n height ~ homeworld, \n \\(x) mean(x, na.rm = TRUE)\n ) |>\n sort_by(~ height, decreasing = TRUE) # hot off the v4.4 press\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n homeworld height\n3 Tatooine 1.792500\n2 Other 1.776471\n1 Naboo 1.772000\n```\n:::\n:::\n\n\nCan't wait to see this roll out into production code. \n\n### Environment {.appendix}\n\n<details><summary>Session info</summary>\n\n::: {.cell}\n::: {.cell-output .cell-output-stdout}\n```\nLast rendered: 2024-05-08 23:33:15 BST\n```\n:::\n\n::: {.cell-output .cell-output-stdout}\n```\nR version 4.4.0 (2024-04-24)\nPlatform: aarch64-apple-darwin20\nRunning under: macOS Ventura 13.2.1\n\nMatrix products: default\nBLAS: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib \nLAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0\n\nlocale:\n[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8\n\ntime zone: Europe/London\ntzcode source: internal\n\nattached base packages:\n[1] stats graphics grDevices utils datasets methods base \n\nother attached packages:\n[1] dplyr_1.1.4\n\nloaded via a namespace (and not attached):\n [1] digest_0.6.35 utf8_1.2.4 R6_2.5.1 fastmap_1.1.1 \n [5] tidyselect_1.2.1 xfun_0.43 magrittr_2.0.3 glue_1.7.0 \n [9] tibble_3.2.1 knitr_1.46 pkgconfig_2.0.3 htmltools_0.5.8.1\n[13] rmarkdown_2.26 generics_0.1.3 lifecycle_1.0.4 cli_3.6.2 \n[17] fansi_1.0.6 vctrs_0.6.5 withr_3.0.0 compiler_4.4.0 \n[21] rstudioapi_0.16.0 tools_4.4.0 pillar_1.9.0 evaluate_0.23 \n[25] yaml_2.3.8 rlang_1.1.3 jsonlite_1.8.8 \n```\n:::\n:::\n\n</details>\n\n[^suffix]: These [suffixes are meaningful](https://aesthetics.fandom.com/wiki/Suffix_Meaning): core 'implies a system, a set of rules', wave 'a significant shift within a genre' and punk 'reject[s] social norms'.\n[^modern]: I called this 'The Modern Base Aesthetic' in [my talk, 'Base Slaps!'](https://www.rostrum.blog/posts/2023-10-17-nhs-r-2023/), at the NHS-R conference 2023. But now I realise the aesthetics run deeper.\n[^poorman]: If you truly want something that looks like {dplyr} code but depends only on base R, then check out [the {poorman} package](https://nathaneastwood.github.io/poorman/).", | ||
"supporting": [], | ||
"filters": [ | ||
"rmarkdown/pagebreak.lua" | ||
], | ||
"includes": {}, | ||
"engineDependencies": {}, | ||
"preserve": {}, | ||
"postProcess": true | ||
} | ||
} |
Oops, something went wrong.