Skip to content

Instantly share code, notes, and snippets.

@Kcnarf
Kcnarf / .block
Last active August 17, 2018 14:16
d3-voronoi-map usage
license: mit
@john-guerra
john-guerra / .block
Last active July 17, 2022 17:15
GeoJson Map of Bogotá
license: mit
library(purrr)
library(dplyr)
row_count <- function(.x, .f){
.f <- as_mapper(.f)
reduce(.x, function(x, y) x + .f(y), .init = 0 )
}
data <- tribble(
~x, ~y, ~z,
@timelyportfolio
timelyportfolio / .block
Last active August 18, 2019 17:07 — forked from ramnathv/concaveman.R
Using Concaveman in R using V8 with beeswarm (fork)
license: mit
height: 100
@klmr
klmr / generator.md
Last active August 28, 2022 02:26
Python-like generators in R

A little experiment using restarts.

(And while we’re at it, let’s torture R’s syntax a little.)

![screenshot][]

In the following we will be using R’s “restarts” feature to implement the state machine that drives generators in languages such as Python. Generators allow lazily generating values on demand: a consumer invokes a generator, and consumes values as they are produced. A new value is only produced once the previous one has been consumed.

@benmarwick
benmarwick / 000_geom_bag.r
Last active March 28, 2024 10:52
Basic bagplot geom for ggplot2
#' Bagplot
#'
#' The bag geom is useful for graphical summaries of scatterplots. It
#' is effective at showing the location, spread, skewness, and
#' outliers of a data set.
#'
#' A bagplot is a bivariate generalization of the well known boxplot. It
#' was proposed by Rousseeuw, Ruts, and Tukey. This geom plots bagplots that
#' are very similar to the one described in Rousseeuw et al. and
#' uses code from their bagplot functions in the aplpack pacakge.
@gluc
gluc / app.R
Last active November 23, 2022 10:14
Shiny CRUD
library(shiny)
library(shinyjs)
# Get table metadata. For now, just the fields
# Further development: also define field types
# and create inputs generically
GetTableMetadata <- function() {
fields <- c(id = "Id",
@trestletech
trestletech / server.R
Last active February 2, 2022 09:47
A Shiny app combining the use of dplyr and SQLite. The goal is to demonstrate a full-fledged, database-backed user authorization framework in Shiny.
library(shiny)
library(dplyr)
library(lubridate)
# Load libraries and functions needed to create SQLite databases.
library(RSQLite)
library(RSQLite.extfuns)
saveSQLite <- function(data, name){
path <- dplyr:::db_location(filename=paste0(name, ".sqlite"))