Skip to content

Instantly share code, notes, and snippets.

View ikashnitsky's full-sized avatar

Ilya Kashnitsky ikashnitsky

View GitHub Profile
@ikashnitsky
ikashnitsky / NEET-in-Europe.R
Last active January 24, 2018 05:14
Young people neither in employment nor in education and training in Europe, 2000-2016
################################################################################
#
# ikashnitsky.github.io 2017-07-18
# Accessing Eurostat data using the `eurostat` R package
# Young people neither in employment nor in education and training in Europe
# Ilya Kashnitsky, [email protected]
#
################################################################################
library(tidyverse)
################################################################################
#
# ikashnitsky.github.io 2017-10-17
# Data acquisition in R - Part 1/4
# https://ikashnitsky.github.io/2017/data-acquisition-one
# Ilya Kashnitsky, [email protected]
#
################################################################################
# load required packages
################################################################################
#
# ikashnitsky.github.io 2017-11-07
# Data acquisition in R - Part 2/4
# https://ikashnitsky.github.io/2017/data-acquisition-two
# Ilya Kashnitsky, [email protected]
#
################################################################################
# load required packages
################################################################################
#
# ikashnitsky.github.io 2017-12-04
# Generate some snow for Sophia
# Ilya Kashnitsky, [email protected]
#
################################################################################
library(tidyverse)
structure(list(stat_levl = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L), shape_area = c(0.0653899829698, 1.3762043666,
1.25499783393, 0.93856596625, 0.427473808209, 0.663122706002,
0.396481635382, 0.613580039208, 0.579619503146, 0.841022895036,
0.872238590611, 0.638449668327, 0.489022847964, 0.685501846886
), shape_len = c(1.22710623792, 7.30786673034, 5.79400468308,
4.37316699851, 3.20638532907, 4.88925982656, 3.36453264071, 4.58107671594,
4.02423661604, 4.33880950383, 5.77002769494, 5.08364809113, 3.24035456572,
4.77048859037), id = c("CZ010", "CZ020", "CZ031", "CZ032", "CZ041",
"CZ042", "CZ051", "CZ052", "CZ053", "CZ063", "CZ064", "CZ071",
################################################################################
#
# ikashnitsky.github.io 2017-12-10
# Data acquisition in R 3/4
# https://ikashnitsky.github.io/2017/data-acquisition-three
# Ilya Kashnitsky, [email protected]
#
################################################################################
@ikashnitsky
ikashnitsky / data-acquisition-one-two-three.R
Last active January 24, 2018 05:12
Code for the Data acquisition in R series (posts 1-3) -- https://habrahabr.ru/post/345664/
################################################################################
#
# ikashnitsky.github.io 2017-12-27
# Data acquisition in R - Parts 1/4, 2/4, 3/4
# For Russian translation at https://habrahabr.ru/post/345664/
# Ilya Kashnitsky, [email protected]
#
################################################################################
# load required packages
@ikashnitsky
ikashnitsky / a-minimal-example.R
Last active January 23, 2018 08:11
Reproducible example for my SO question on how to fit 2 sf seamlessly -- https://stackoverflow.com/questions/48360446
# install dev version of ggplot2
devtools::dev_mode()
devtools::install_github("tidyverse/ggplot2")
library(tidyverse)
library(sf)
library(rmapshaper)
library(ggthemes)
@ikashnitsky
ikashnitsky / rgb-ternary.R
Created April 26, 2018 13:56
a minimal example of an RGB colorcoded ternary diagram
# a function from: Schöley, J., & Willekens, F. (2017). Visualizing compositional data on the Lexis surface. Demographic Research, 36(21), 627–658. https://doi.org/10.4054/DemRes.2017.36.21
TernaryCentroidCoord <- function (k) {
centroids <- matrix(nrow = k^2, ncol = 5,
dimnames = list(NULL, c("j", "i", "p1", "p2", "p3")))
for (j in 1:k) {
for (i in 1:(2*k - 2*j + 1)) {
p1 = (6*k - 6*j - 3*i + 4 + i%%2) / (6*k)
p2 = (6*j - 2 - 2*i%%2) / (6*k)
p3 = (3*i - 2 + i%%2) / (6*k)
centroids[i+(j-1)*(2*k-j+1),] = c(j, i, p1, p2, p3)
@ikashnitsky
ikashnitsky / get-all-sjr-data.r
Created September 22, 2018 11:58
Get all SCImago Journal & Country Rank data (script version of sjrdata package)
################################################################################
#
# bibliometrics 2018-09-22
# SJR data -- load and combine all files -- GIST
# Ilya Kashnitsky, [email protected]
#
################################################################################
library(tidyverse)
library(janitor)