Skip to content

Instantly share code, notes, and snippets.

View uribo's full-sized avatar
🍉
fine

Shinya Uryu uribo

🍉
fine
View GitHub Profile
require("sf")
require("dplyr")
require("hexbin")
# Linux libertine font "sf", converted to path with Inkscape,
# added points between existing points 2 times, then turned all segments into straight lines.
# Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data).
# Loaded coords from SVG source code, remove letters from start and end, and replace " " with ","
coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944,
@nuest
nuest / sf-hexagon-with-sf.R
Created January 11, 2018 14:17
sf hexagon sticker with sf
library("sf")
library("dplyr")
library("hexbin")
# Linux libertine fint "sf", converted to path with Inkscape,
# added points between existing points 2 times, then turned all segments into straight lines.
# Saved as SVG with absolute coordinates (Preferences > SVG Output > Path Data).
# Loaded coords from SVG source code, remove letters from start and end, and replace " " with ","
coords_f <- c(218.1169,163.46992,215.56952,177.96334,213.51976,189.84421,211.82546,200.33884,210.34442,210.67351,208.24728,226.35176,205.51032,243.54066,201.92029,259.27223,197.26391,270.57846,195.45112,272.90665,193.28288,274.70167,190.97247,275.85687,188.73314,276.26564,187.03291,276.03164,185.79476,275.38887,184.84097,274.42619,183.99382,273.23248,182.45947,271.13533,180.24976,269.10927,177.54243,267.58084,174.51519,266.97658,171.25987,267.58973,169.08867,269.18036,167.87718,271.37526,167.501,273.8012,168.44294,277.0032,171.48203,279.79643,176.93817,281.77214,185.13126,282.52154,191.01986,281.80176,196.83737,279.60686,202.29944,
@tai2
tai2 / money.md
Last active October 6, 2019 13:58
フリーランス6年目の収入
@ikosmidis
ikosmidis / let_it_snow.R
Last active December 25, 2017 09:32
A function to create artifical snow using R base graphics and the animation package
## Licence: GPL 2 or 3 <https://www.gnu.org/licenses/licenses.html#GPL>
## Author: Ioannis Kosmidis <[email protected]>
## Date: 21 December 2017
#' A function to create artifical snow using R base graphics and the animation package
#'
#' @param n_flakes how many flakes to throw?
#' @param fall_speed how fast should the snow fall? There will be a \code{1/fall_speed} seconds delay between moves
#' @param max_flake_size what is the maximum flake size (same as cex in \code{\link{plot}})
#' @param eps how much is the flake allowed to move to the left and to the right? (emulating wind)
@kaz-yos
kaz-yos / base_r_to_tidyverse.txt
Created October 12, 2017 15:51
Switching from Base R to tidyverse
Taken from http://www.significantdigits.org/2017/10/switching-from-base-r-to-tidyverse/
| Base R command | Tidyverse Command | Comment |
|-----------------------------------+--------------------------------------------+---------------------------------------------------------------|
| read.csv() | read_csv() | also see read_delim(), read_tsv() and readxl::read_xlsx() |
| sort(), order() | arrange() | see also order_by() |
| mtcars$mpg = ... | mutate() | see also transmute() which drops existing variables |
| mtcars[,c(“mpg”, “am”)], subset() | select(), rename() | see also pull() |
| mtcars[mtcars$am == 1,], subset() | filter()
@wookietreiber
wookietreiber / git-hook-lintr.r
Last active April 1, 2019 22:11
git pre-commit hook to check R scripts with lintr via littler
suppressMessages(library(lintr))
files <- commandArgs(trailingOnly = T)
messages <- function(file) {
result <- lint(file)
print(result)
return(length(result))
}
@cpsievert
cpsievert / europe.R
Last active December 1, 2017 23:05 — forked from halhen/europe.R
library(tidyverse)
library(plotly)
# I'm being lazy, please don't do this
# setwd("~/Downloads/Version 2_0_1/")
d <- read_csv('GEOSTAT_grid_POP_1K_2011_V2_0_1.csv') %>%
rbind(read_csv('JRC-GHSL_AIT-grid-POP_1K_2011.csv') %>%
mutate(TOT_P_CON_DT = '')) %>%
mutate(
@timelyportfolio
timelyportfolio / .block
Last active November 28, 2019 00:42
R leaflet popups with sparkline htmlwidget
license: mit
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@hrbrmstr
hrbrmstr / .aOECDGenderDiff.md
Last active March 2, 2017 17:45
Still needs finishing work for but this is def better than https://twitter.com/thosjleeper/status/836957509546098690