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
/* rs-theme-name: Dark UI Base16 Tomorrow Night */ | |
/* rs-theme-is-dark: TRUE */ | |
/* Dark UI from Randy3k's Wombat (https://github.com/randy3k/dotfiles/blob/master/.R/rstudio/themes/Wombat.rstheme) */ | |
/* "Tomorrow night" color scheme adapted from chriskempson's Base16 (https://github.com/chriskempson/base16). */ | |
.body { | |
background: #ffffff; | |
} |
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
# triangle.py | |
import math | |
def triangle_perimeter(a, b, c): | |
return a + b + c | |
def triangle_area(a, b, c): | |
p = triangle_perimeter(a, b, c) / 2 | |
x = math.sqrt(p * (p - a) * (p - b) * (p - c)) | |
return round(x, 2) |
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
# package dependency | |
library(haven) | |
path_in = "new_EB with more var_2004-2016.dta" | |
out_tsv = "new_EB.tsv" | |
out_sav = "new_EB.sav" | |
# name repair shows the issue with _merge | |
x = haven::read_dta(p, .name_repair = "universal") | |
names(x)[ names(x) == "._merge" ] = "MERGEVAR" |
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
x = c("Aaltonen, Markus Sakari", "Stubb, Cai-Göran Alexander", "Ahde, Matti Allan", | |
"Saarakkala, Vesa-Matti", "Aho, Esko Tapani", "Piirainen, Raimo Olavi", | |
"Jääskeläinen, Pietari Osmo", "Juurikkala, Timo Johannes", | |
"Jokinen, Kalle Johannes", "Aho, Raila Orvokki", "Ahonen, Risto Sakari", | |
"Aittoniemi, Sulo Eerikki", "Ahvenjärvi, Sauli Sakari", "Mäkisalo-Ropponen, Merja Elina", | |
"Mäntylä, Hanna Katariina", "Autto, Heikki Samuli", "Ajo, Aimo Olavi", | |
"Mäntymaa, Markku Antero", "Mölsä, Martti Kullervo", "Niikko, Mika Ilari", | |
"Eerola, Juho Seppo Antero", "Eestilä, Markku Yrjö", "Packalén, Tom Erik", | |
"Elomaa, Ritva Tuulikki", "Pekonen, Aino-Kaisa Ilona", "Pelkonen, Jaana Maarit", | |
"Eloranta, Eeva-Johanna", "Donner, Jörn Johan", "Grahn-Laasonen, Sanni Kaisa", |
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
*! 0.2.3 F. Briatte 20mar2013 | |
cap pr drop svyplot | |
program svyplot | |
syntax varlist(max=3) [if] [in] [aweight fweight iweight/] /// | |
[, Reds Blues Ascending Descending Horizontal Ymax(int 100) /// | |
Float(int 0) Size(real 3.5) ANGLE(int 0) NOPercent XLAb *] | |
// parse options |
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
# Original by Kevin Ushey: | |
# https://raw.githubusercontent.com/kevinushey/etc/master/dotfiles/.Rprofile | |
.First <- function() { | |
# only run in interactive mode | |
if (!interactive()) | |
return() | |
# create .Rprofile env |
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
# change of PRNG in R >= 3.6.0 | |
# use former PRNG | |
RNGkind(sample.kind = "Rounding") | |
# use new/fixed PRNG | |
RNGkind(sample.kind = "default") | |
# see ?Random for details |
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(cartography) | |
library(sp) | |
# Load data | |
data(nuts2006) | |
# Get a SpatialLinesDataFrame of countries borders | |
nuts0.contig.spdf <- getBorders(nuts0.spdf) | |
# Get the GDP per capita | |
nuts0.df$gdpcap <- nuts0.df$gdppps2008/nuts0.df$pop2008*1000000 |
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
## | |
## download all `ergm` sources from v3.0-1 to today | |
## | |
library(rvest) | |
d <- "ergm-sources" | |
dir.create(d, showWarnings = FALSE) | |
# current source |
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(tidyverse) | |
library(patchwork) | |
plot_pair <- function(data, x, y) { | |
ggplot(data, aes_string(x = x, y = y, color = "Species", shape = "Species")) + | |
geom_point() + | |
scale_color_brewer(palette = "Dark2") + | |
theme(legend.position = "none", plot.title = element_text(size = 7)) + | |
labs(x = NULL, y = NULL, title = paste0(y, " ~ ", x)) |