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

It seems we need to wait ARROW-3543 for preserving timezones.

library(arrow)
#> 
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#> 
#>     timestamp
devtools::load_all("~/repo/R/ggplot2")
#> Loading ggplot2

p <- ggplot(base::data.frame(x = 1:3)) +
  geom_point(aes(x, x, colour = x))

get_colourbar <- function(nbin) {
  p <- p + scale_color_gradient(
 paste0("nbin =\n", nbin),
@yutannihilation
yutannihilation / multiple-textGrob.md
Last active August 20, 2019 03:29
It seems the grob settings are vectorized over x and y
library(grid)

g <- textGrob(
  label = c("1", "2", "3"),
  gp = gpar(
    fontsize = 1:3 * 50,
    cex = 1,
    fontfamily = "",
 fontface = "plain",
library(httr)
library(rvest)
#> Loading required package: xml2

res <- read_html("https://mutable-instruments.net/modules/")

available_modules <- res %>%
  html_node("div.Grid-container[data-category='all']") %>%
 html_nodes("a.Grid-cell")
library(ggplot2)

ggplot(mpg, aes(displ, hwy, colour = displ > 4)) +
  geom_point() +
  geom_smooth()
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'

let steps = 100;
let offset = 0;
function drawStripeCircle(steps) {
clear();
let r = min(width, height);
let a = 2 * PI / steps;
for (let i = 0; i < steps; i++) {
library(ggplot2)
p <- ggplot(mtcars, aes(factor(cyl))) +
geom_bar(aes(fill = factor(cyl)))
p + scale_x_discrete(limits = c("4", "8"))
p + scale_fill_discrete(limits = c("4", "8"))
cols <- c("8" = "red", "4" = "blue", "6" = "darkgreen", "10" = "orange")
p + scale_fill_manual(values = cols, limits = c("4", "8"))
library(ggplot2)
`%||%` <- rlang::`%||%`
f1 <- body(geom_abline)
f2 <- body(function(x) sum(x))
f3 <- body(function(...) sum(x, ...))
any_dots <- function(call_args) {
any(purrr::map_lgl(call_args, identical, quote(...)))
date <- as.Date("2017-01-01")
integer <- 1L
c(date, integer)
#> [1] "2017-01-01" "1970-01-02"
c(integer, date)
#> [1] 1 17167
`+`(date, integer)
#> [1] "2017-01-02"
@yutannihilation
yutannihilation / clip_lines_adhoc.md
Last active February 22, 2019 02:11
Clipping lines using isoband::clip_lines()
library(ggplot2)
library(grid)

geom_clipped_line <- function(mapping = NULL, data = NULL, stat = "identity",
                              position = "identity", na.rm = FALSE,
                              show.legend = NA, inherit.aes = TRUE, ...) {
  layer(
    data = data,
    mapping = mapping,