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(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')
#> Error in col[, rep(1, length(alpha)), drop = FALSE]: subscript out of bounds
# 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),
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()
#> Error in list() + list(): non-numeric argument to binary operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
output: github_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
orig_hook <- knitr::knit_hooks$get("output") | |
knitr::knit_hooks$set( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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引数に指定する |
nest_join()
はfull_join()
以外のjoinを一般化するものらしい。おもしろい。
nest_join()
is the most fundamental join since you can recreate the other joins from it. Aninner_join()
is anest_join()
plus an [tidyr::unnest()], andleft_join()
is anest_join()
plus anunnest(drop = FALSE)
. Asemi_join()
is anest_join()
plus afilter()
where you check that every element of data has at least one row, and ananti_join()
is anest_join()
plus afilter()
where you check every element has zero rows.
group_by() %>% nest()
のショートカット。↑のExamplesのコードがわかりやすいのでそのまま実行してみる。
library(dplyr, warn.conflicts = FALSE)
func1 <- function(dummy = 1) {
missing(dummy)
}
func1()
#> [1] TRUE
func2 <- function(dummy = 1) {
func1(dummy=dummy)