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

参考

nest_join()full_join()以外のjoinを一般化するものらしい。おもしろい。

nest_join() is the most fundamental join since you can recreate the other joins from it. An inner_join() is a nest_join() plus an [tidyr::unnest()], and left_join() is a nest_join() plus an unnest(drop = FALSE). A semi_join() is a nest_join() plus a filter() where you check that every element of data has at least one row, and an anti_join() is a nest_join() plus a filter() where you check every element has zero rows.

library(leaflet)
# 先にbasemapをつくっておく
basemap <- leaflet() %>%
addTiles("http://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png",
attribution = "<a href='http://maps.gsi.go.jp/development/ichiran.html' target='_blank'>地理院タイル</a>")
library(mapview)
# つくったbasemapをmap引数に指定する
@yutannihilation
yutannihilation / knitr-hook.Rmd
Created August 8, 2018 14:19
Use knitr's output hook to hide path
---
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
orig_hook <- knitr::knit_hooks$get("output")
knitr::knit_hooks$set(
foo <- function(x = list()) structure(x, class = "foo")
`+.foo` <- function(e1, e2) message("foo!")

bar <- function(x = list()) structure(x, class = "bar")
`+.bar` <- function(e1, e2) message("bar?")

# unaddable, no methods
list() + list()
#&gt; Error in list() + list(): non-numeric argument to binary operator
# https://github.com/GuangchuangYu/shadowtext/blob/master/vignettes/shadowtext.Rmd
library(ggplot2)
library(shadowtext)

random_text <- function(n=1, length=10) {
  d <- data.frame(n=1:n, length=length)
  sapply(1:nrow(d), function(i) {
    paste(sample(c(0:9, letters, LETTERS),
                 d$length[i], replace=TRUE),
library(ggplot2)
# To reproduce this error shadowtext is installed from source, not binary.
library(shadowtext)

set.seed(1)
d <- data.frame(x = rnorm(3), y=rnorm(3), label = c('hello', 'world', '!!!'))
ggplot(d, aes(x,y)) +
  geom_shadowtext(aes(label=label, color=label), bgcolor='firebrick')
#&gt; Error in col[, rep(1, length(alpha)), drop = FALSE]: subscript out of bounds
library(tidyverse)
library(gghighlight)

d <- mtcars %>%
  #filter(drat >= 3) %>%
  select(mpg,disp,hp,drat) %>%
  gather(variable, value, -disp, -hp, -drat) 
d
#>     disp  hp drat variable value
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) +
# 参考:
# - 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