Skip to content

Instantly share code, notes, and snippets.

View yutannihilation's full-sized avatar
🍣
Nobody loves you

Hiroaki Yutani yutannihilation

🍣
Nobody loves you
View GitHub Profile
library(ggplot2)

# functions -----------------------------------------------

geom_liquid_area <- function(mapping = NULL, data = NULL, stat = "identity",
                             position = "stack", na.rm = FALSE, show.legend = NA,
                             inherit.aes = TRUE, ...) {
  layer(
    data = data,
@yutannihilation
yutannihilation / mitmproxy.R
Created December 14, 2018 23:33
Use mitmproxy with R (not working yet)
tmp <- file.path(normalizePath(tempdir()), "certs")
dir.create(tmp)
download.file("https://curl.haxx.se/ca/cacert.pem", file.path(tmp, "cacert-mozilla.pem"), mode = "wb")
library(httr)
proxy_conf <- use_proxy("http://127.0.0.1", port = 8080)
res <- GET("http://mitm.it/cert/pem", config = proxy_conf)
writeBin(content(res), file.path(tmp, "cacert-mitm.pem"))
library(dplyr, warn.conflicts = FALSE)

df <- tibble(
  f1 = factor(c("a", "a", "a", "b", "b"), levels = c("a", "b", "c")), 
  f2 = factor(c("d", "e", "d", "e", "f"), levels = c("d", "e", "f")), 
  x  = c(1, 1, 1, 2, 2), 
  y  = 1:5
)
@yutannihilation
yutannihilation / read_parquet.md
Last active August 1, 2019 05:28
Read parquet files from R by using Apache Arrow

Read Parquet files from R

Prerequisite

Install libarrow and libparquet.

git clone https://github.com/apache/arrow/
@yutannihilation
yutannihilation / arrow.md
Last active December 5, 2018 03:03
Apache Arrow東京ミートアップ2018用のメモ
library(tidyverse)
library(magick)
# the speed of involute increases uniformly; in order to make the lengths between
# steps equal, we need to calculate the square root
resolution_of_involute <- 10000L
t <- sqrt(seq(0, resolution_of_involute) / resolution_of_involute)
coil_turns <- 17L
max_r <- coil_turns * 2 * pi
library(tidyverse)
library(magick)
#> Linking to ImageMagick 6.9.9.14
#> Enabled features: cairo, freetype, fftw, ghostscript, lcms, pango, rsvg, webp
#> Disabled features: fontconfig, x11


img_file <- tempfile(fileext = ".png")
download.file("https://hoxo-m.com/img/team/makiyama.png", destfile = img_file, mode = "wb")
library(tidyverse)
library(magick)
steps <- 10000L
coil_turns <- 3L
max_r <- coil_turns * 2 * pi
imgs <- image_graph(300, 300, res = 30)
rotation <- pi/4

c.f. tidyverse/ggplot2#2881

library(ggplot2)
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3

nc <- st_read(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE)

ggplot() +