Skip to content

Instantly share code, notes, and snippets.

View georgestagg's full-sized avatar

George Stagg georgestagg

View GitHub Profile
@georgestagg
georgestagg / app.R
Last active May 21, 2024 08:28
Shinylive for R - Loading data in various formats
library(shiny)
library(bslib)
library(duckplyr)
data1 <- readRDS("data.rds")
data2 <- read.csv("data.csv")
data3 <- df_from_parquet("data.parquet")
ui <- page_fillable(
titlePanel("Example: loading data formats"),
@georgestagg
georgestagg / mandeldrop.R
Created July 26, 2022 19:03
Mandelbrot set, transformed into a teardrop shape, in R and Rcpp
Rcpp::sourceCpp("mandeldrop.cpp")
xlims=c(-0.65,0.65)
ylims=c(-0.6,2.2)
m <- mandeldrop(xlims[[1]], xlims[[2]], ylims[[1]], ylims[[2]], 1560, 2160, 512)
# Colour palette from https://stackoverflow.com/q/48069990
rainbow=c(rgb(0.47,0.11,0.53),rgb(0.27,0.18,0.73),rgb(0.25,0.39,0.81),rgb(0.30,0.57,0.75),rgb(0.39,0.67,0.60),rgb(0.51,0.73,0.44),rgb(0.67,0.74,0.32),rgb(0.81,0.71,0.26),rgb(0.89,0.60,0.22),rgb(0.89,0.39,0.18),rgb(0.86,0.13,0.13))
cols=c(colorRampPalette(rainbow)(100),rev(colorRampPalette(rainbow)(100)),"black")