Skip to content

Instantly share code, notes, and snippets.

title
Testing svg in mathjax

Run with:

pandoc -s --mathjax test-die.md -o test-die.html
library(ggplot2)
library(grid)
element_box_break <- function (fill=NULL, colour = NULL, linewidth = NULL, linetype = NULL, lineend = NULL,
color = NULL, arrow = NULL, inherit.blank = FALSE) {
if (!is.null(color))
colour <- color
if (is.null(arrow))
arrow <- FALSE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language name="Julia" section="Scientific"
version="0"
extensions="*.jl"
mimetype="text/x-juliascript"
author="Andreas Nordal ([email protected])"
license="public domain">
<highlighting>
library(ggplot2)
library(readr)
library(ggfittext)
d <- read_csv('PrevalenceAtLarge.csv')
d$value <- cut(d$PercentAtLarge, breaks = 5,
labels = c("doubling under 6 weeks",
"doubling in 2–6 weeks",
"stable",
"halving in 2–6 weeks",
library(ggplot2)
library(tagger)
d <- data.frame(x=rep(1:10, 5*4*2), y=rnorm(10*5*4*2), f1=gl(4,10*5*2,labels=letters[1:4]), f2=gl(5,10*4*2,labels = LETTERS[1:5]), f3=gl(2,10*4*5))
p <- ggplot(d, aes(x,y)) +
facet_wrap(f1~f2+f3)
data <- ggplot_build(p)
str(data$layout$layout)
# 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