library(tidyverse)
example_draws <- tribble(
~category, ~shapes,
FALSE, c(10, 10, 13),
TRUE, c(7, 7, 8)
) |>
mutate(draws = map(shapes, ~{
withr::with_seed(1234, {
library(raster) | |
library(rayshader) | |
library(terrainr) | |
library(sf) | |
Rainier <- tmaptools::geocode_OSM("Mount Rainier") | |
Rainier <- st_as_sf(as.data.frame(t(as.data.frame(Rainier$coords))), coords = c("x", "y"), crs = 4326) | |
zscale <- 5 | |
Rainier <- set_bbox_side_length( | |
Rainier, |
library(dplyr) # for data processing | |
library(tidyr) # for data processing | |
library(magick) # for image reading and OCR | |
library(tesseract) # for OCR | |
# read image | |
dataimg <- magick::image_read("https://pbs.twimg.com/media/FBv8P8XXEBgCBvS?format=jpg&name=medium") | |
# convert image to text | |
text <- magick::image_ocr(dataimg) |
(This post was motivated by a talk by @jnolis at CascadiaRConf 2021)
Recent versions of Shiny have an undocumented feature for handling POST requests that are not associated with any specific Shiny session. (Note that this functionality is missing our normal level of polish; it's a fairly low-level hook that I needed to make some things possible, but doesn't make anything easy.)
In a nutshell, it works by replacing your traditional ui
object with a function(req)
, and then marking that function with an attribute indicating that it knows how to handle both GET
and POST
:
library(shiny)
library(tidyverse) | |
library(forcats) | |
# The original plot | |
## This has an ugly legend title, maybe we should remove it and modify the labels | |
ggplot(mtcars, aes(x = mpg, y = disp, col = as.factor(cyl))) + | |
geom_point() | |
# Approach 1: Modify the plot |
Playing around with Boids-style flocking. Click to add more, coloring by movement colors each boid by a moving average of its acceleration magnitude.
See also: Particle tentacles
More boids:
boids by Hugh Kennedy
boids-canvas by Mike Christensen
boids demo by Anoop Elias
flocking in Processing by Daniel Shiffman
{"nodes":[{"id":"4062045","user":"mbostock","description":"Force-Directed Graph"},{"id":"1341021","user":"mbostock","description":"Parallel Coordinates"},{"id":"1341281","user":"jasondavies","description":"Parallel Coordinates"},{"id":"b3ff6ae1c120eea654b5","user":"d3noob","description":"Simple d3.js Graph"},{"id":"4963004","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4962892","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4963273","user":"calvinmetcalf","description":"Quadtree Madness Round 2"},{"id":"4967213","user":"calvinmetcalf","description":"Rtree Madness"},{"id":"4060606","user":"mbostock","description":"Choropleth"},{"id":"4686432","user":"dwtkns","description":"Faux-3d Shaded Globe"},{"id":"3757101","user":"mbostock","description":"Lambert Azimuthal Equal-Area"},{"id":"5028304","user":"d3noob","description":"Sankey diagram with horizontal and vertical node movement"},{"id":"4343214","user":"mbostock","description":"Quadtree"},{"id":"1346410","user" |
library(tidyverse) | |
library(ggalt) # devtools::install_github("hrbrmstr/ggalt") | |
df <- data_frame( | |
benchmark=c(0.52, 0.57, 0.60, 0.63, 0.64, 0.67), | |
referrals=c(4.2, 4.5, 4, 4.5, 3.9, 3.6), | |
year=c(2011, 2012, 2013, 2014, 2015, 2016) | |
) | |
# as of 2016-11-07 ggplot2 geom_label() seems to be ignoring the "angle" parameter, hence the non-ideal use of geom_text() |
license: mit |
library(ggplot2) | |
library(animation) | |
library(circular) | |
# utility functions for trajectory generation ------------------- | |
# - these function came from motAnalysis package | |
random.positions <- function(n, xlim = c(-10, +10), ylim = xlim, | |
dot.radius = 0.5, min.dist = 1) { | |
pos <- list( |