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(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() + 
# 参考:
# - https://github.com/rwinlib/arrow
# - https://github.com/apache/arrow/blob/master/cpp/apidoc/Windows.md#building-using-visual-studio-msvc-solution-files
# Update packages
pacman -Syu
pacman -Su
# Use Rtools
export CC=/c/Rtools/mingw_64/bin/gcc
library(tidyverse)
library(gghighlight)

mtcars %>%
  select(mpg,cyl,disp,hp,drat) %>%
  gather(variable, value, -disp, -hp, -drat, -cyl) %>%
  mutate(cyl = factor(cyl)) %>% 
  ggplot(aes(disp,value,color=factor(drat))) +
 facet_wrap( ~ cyl, labeller = label_both, drop = FALSE) +