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
## Goal: reproduce e.g. https://www.reddit.com/r/oddlysatisfying/comments/uc054a/lissajous_polygons | |
using Plots | |
import GeometryBasics: Point | |
## https://jcarroll.xyz/2022/04/07/interpolation-animation-in.html | |
interpolate(a, b) = t -> ((1.0 - t) * a + t * b) | |
## define the vertices of an N-gon |
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
starts_with_ordered <- function(match, decreasing = FALSE) { | |
all_vars <- tidyselect::peek_vars() | |
matches <- tidyselect::starts_with(match) | |
named_matches <- setNames(matches, all_vars[matches]) | |
named_matches[order(names(named_matches), decreasing = decreasing)] | |
} | |
mtcars |> | |
dplyr::select(starts_with_ordered("c", decreasing = FALSE)) |> | |
head() |
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(SummarizedExperiment) | |
## create a SummarizedExperiment | |
se <- SummarizedExperiment(assays = | |
list( | |
counts = matrix(0:99, 10, 10), | |
cpm = matrix(200:299, 10, 10) | |
) | |
) | |
## add tabular metadata with assay-specific properties |
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
## Inspired by | |
## https://twitter.com/ted_dunning/status/1435027697386721280?s=20&t=cDVb0XOQRJeOjXoTrOz54w | |
using Plots | |
## These are required to be imported to write methods for them | |
import Base:* | |
import Base:+ |
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
## How should we write non-reactive (business logic) functions so that they | |
## are maximally compatible with shiny/reactive processing? | |
## Here's a function which performs business logic. It may be used at the | |
## console or it may be used in a shiny app. | |
## A shiny app will probably provide the right type of input so the | |
## input validations are perhaps not as critical, but a typical design | |
## is to stop() if a critical condition is not met during calculations. | |
var_top_cars <- function(d, minval) { | |
stopifnot("mpg not found" = utils::hasName(d, "mpg")) |
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(dplyr) | |
## fake data | |
d <- mtcars %>% | |
group_by(cyl) %>% | |
summarise(lower = min(disp), | |
med = median(disp), | |
upper = max(disp)) | |
p <- ggplot(d, aes(x = factor(cyl), y = med)) + |
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(COVID19) | |
library(dplyr) | |
library(zoo) # rollmean | |
library(ggplot2) | |
library(ggeasy) # easy_add_legend_title | |
#### deaths #### | |
## gather USA data at state level and identify weekends | |
us <- covid19("USA", level = 2) %>% |
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
# Fork of https://gist.github.com/johnburnmurdoch/1d23978fc8213ff656d9f629608dd1f5/revisions | |
# modified to work with https://github.com/nacnudus/google-location-coronavirus | |
# Install and load required packages | |
# install.packages("needs") | |
# library(needs) | |
# needs(tidyverse, magrittr, animation, pdftools, png, scales) | |
library(tidyverse) | |
library(magrittr) | |
library(animation) |
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(htmltools) | |
library(d3r) | |
library(eulerr) | |
ui <- list( | |
attachDependencies( | |
tagList(), | |
d3_dep_v5() | |
), | |
titlePanel("Interactive Set Selector"), |
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
fastsort <- function(x, partial) { | |
y <- if (length(partial) <= 10L) { | |
partial <- .Internal(qsort(partial, FALSE)) | |
.Internal(psort(x, partial)) | |
} | |
else { | |
.Internal(qsort(x, FALSE)) | |
} | |
y | |
} |