Skip to content

Instantly share code, notes, and snippets.

# not needed
# library(ggplot2)
# disclaimer: this code is from 15 years ago...
# (kind of impressed it still runs!)
# example data
x <- seq(0, 10, len = 100)
y1 <- jitter(sin(x), 1000)
@baptiste
baptiste / file1.qmd
Last active February 15, 2023 20:29
code externalisation in quarto
---
title: "file 1"
format: html
---
## Code Externalisation
Write R code in external R scripts, and use `read_chunk()` to read them into the current document.
```{r cache=FALSE}
```{r}
path <- fs::path("<<variable>>", ext = "csv")
cmd <- paste0("{{< downloadthis ", "'", path, "'", ' dname=<<variable>> label="Download the <<variable>> data" icon=database-fill-down type=info class=data-button id=<<variable>> >}}')
```
```{r}
#| results: asis
cat(cmd)
@baptiste
baptiste / rss.R
Last active January 4, 2023 04:08
library(minixml)
# devtools::install_github("coolbutuseless/minixml")
library(anytime)
generate_empty_feed <- function(file = 'index.xml'){
doc <- xml_elem("rss", version="2.0")
channel <- doc$add('channel')
channel$add('title', "Photography")
channel$add('link', "https://photo.bapt.xyz/")
channel$add('description', "My latest photo pages")
grab_math_strings <- function(fe){
parse <- readLines(glue("{fe}-math.tex"))
content <- parse[parse != '']
lines <- grep("math start", content)
start <- lines+1
end <- c(lines[-1], length(content) + 1) - 1
---
title: "A graphics workflow"
author: "baptiste"
date: 2018-20-05
---
Glyphs are positioned by x and y coordinates; other parameters are kept separate as they may differ from glyph to glyph and, crucially, compound glyphs contain nested glyphs with their own properties, requiring a flexible container.
The structure of a glyph is thus as follows,
# library(cubs)
library(Ryacas)
Ylm <- function(l,m,phi,theta){
ex <- Ryacas::yac_expr(glue::glue("(-1)^{m}*(1-x^2)^({m}/2)*D(x,{m})OrthoP({l}, x)"))
sqrt((2*l+1)/(4*pi) * factorial(l-m) / factorial(l+m))*
exp(1i*abs(m)*phi) * eval(ex, list(x = cos(theta)))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
library(vwline)
library(gridGeometry)
library(hershey)
library(ggplot2)
library(scales)
w <- c(0, .2, 0)
gl <- list()