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
eq <- r"($\displaystyle\sigma_\mathrm{abs} = \frac{2\pi}{n\lambda |\mathbf{E_0}|^2}\int_0^{2\pi}\int_0^{\pi}\int_{r_1}^{r_2}\varepsilon''|\mathbf{E}|^2 r^2\sin\theta\,\mathrm{d}r\mathrm{d}\theta\mathrm{d}\varphi$)" | |
library(glue) | |
library(grImport2) | |
library(grid) | |
latex <- function(s){ | |
tmp <- tempfile(tmpdir = '.') | |
doc <- glue('\\documentclass[border=5pt]{minimal}\\begin{document}<s>\\end{document}', |
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
library(ggplot2) | |
model <- function(phi, theta){ | |
yl35m27 = Re(-exp(27i*phi)*sin(theta)^27*(180297*cos(theta)^8 - 73164*cos(theta)^6 + 8190*cos(theta)^4 - 252*cos(theta)^2 + 1)) | |
yl12mm7 = Re((exp(-7i* phi)* sin(theta)^7* cos(theta)* (161 *cos(theta)^4 - 70* cos(theta)^2 + 5))) | |
yl12m0 = Re(5 *(676039* cos(theta)^12 - 1939938 * cos(theta)^10 + 2078505 * cos(theta)^8 - 1021020 * cos(theta)^6 + 225225 * cos(theta)^4 - 18018 * cos(theta)^2 + 231)/2000) |
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
library(ggplot2) | |
library(egg) | |
library(extrafont) | |
library(xkcd) | |
library(grid) | |
d <- data.frame(x=rep(-1:1,3),y=0,facet=rep(1:3,each=3)) | |
p0 <- ggplot(d, aes(x,y)) + | |
facet_wrap(~facet, labeller = label_both) + |
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
library(glue) | |
make_header <- function(css = 'svg.css') | |
glue( | |
'<?xml version="1.0" encoding="utf-8"?> | |
<?xml-stylesheet type="text/css" href="{css}"?> | |
<svg viewBox="0 0 576 216" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">', css = css) | |
make_defs <- function() | |
' |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
library(egg) | |
library(gridExtra) | |
library(ggplot2) | |
library(grid) | |
d <- data.frame(x=runif(10*7), | |
y=runif(10*7), | |
f1 = gl(7,10), | |
f2 = gl(3, 30, 7*10)) |
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
library(leaflet) | |
library(rayshader) | |
library(raster) | |
library(geoviz) | |
# define bounding box with longitude/latitude coordinates | |
bbox <- list( | |
p1 = list(long = 172, lat = -41.0), | |
p2 = list(long = 173.1, lat = -40.4) | |
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
library(ggplot2) | |
set.seed(1221) | |
dat <- data.frame(x=rnorm(100), y=rnorm(100), type=rep(1:2, each=50)) | |
p <- ggplot(dat) + geom_point(aes(x, y)) + | |
facet_wrap(~type) + coord_fixed() + | |
theme(plot.background = element_rect(fill='red')) | |
# inspired by | |
# egg::set_panel_size |
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
library(rmarkdown) | |
pre_knit <- function(input, ...){ | |
rd <- readLines(input) | |
id <- grep('◊', rd) | |
rd[id] <- stringr::str_replace_all(rd[id], | |
"`◊([:alnum:]+)\\((.*?)\\)`", | |
replacement = '`r \\1("\\2")`') | |
file.copy(input, paste0(input, 'original.Rmd')) | |
writeLines(text = rd, con = input) |