Skip to content

Instantly share code, notes, and snippets.

View agricolamz's full-sized avatar

George Moroz agricolamz

View GitHub Profile
@agricolamz
agricolamz / arc_lingtypology.R
Created January 21, 2018 06:51
Creating arc-line in lingtypology
library(lingtypology)
library(geosphere)
d <- gcIntermediate(c(5, 52),
c(47, 43),
n = 100,
addStartEnd = TRUE,
sp = TRUE)
co <- as.data.frame(d@lines[[1]]@Lines[[1]]@coords)
@agricolamz
agricolamz / evaluate.R
Created February 23, 2018 07:08
This is a simple console program in R
#!/usr/bin/env Rscript
require(docopt, quietly = TRUE)
'Usage:
calculate.R [-n <nlines>]
Options:
-n Number of stdin lines [default: 1]
]' -> doc
@agricolamz
agricolamz / wave_visualisation.R
Created February 23, 2018 07:13
This file visualise multiple simple waves and their summation
library(tidyverse)
t <- seq(0,0.5, 0.001)
`500 Hz` <- sin(1*5*2*pi*t)
`1000 Hz` <- sin(2*5*2*pi*t)
`1500 Hz` <- sin(3*5*2*pi*t)
`2000 Hz` <- sin(4*5*2*pi*t)
`2500 Hz` <- sin(5*5*2*pi*t)
`500 + 500 Hz` <- sin(1*5*2*pi*t) + sin(1*5*2*pi*t)
`1000 + 500 Hz` <- sin(2*5*2*pi*t) + sin(1*5*2*pi*t)
`1500 + 500 Hz` <- sin(3*5*2*pi*t) + sin(1*5*2*pi*t)
@agricolamz
agricolamz / telegram_bot.R
Created February 23, 2018 07:15
This is a simple telegram bot
# from here https://github.com/lbraglia/telegram
library(telegram)
bot <- TGBot$new(token = bot_token('hseling_bot'))
bot$set_default_chat_id(407084056)
Sys.time()
md1 <- "*bold* _italic_ [r-project](http://r-project.org) "
md2 <- " try `x <- rnorm(100)` at the console ..."
## below left spaces just for github displaying (not needed in the .R src)
@agricolamz
agricolamz / udipipe_test.R
Created February 23, 2018 07:17
Testing udipipe package
library(udpipe)
model <- udpipe_download_model(language = "polish")
model <- udpipe_load_model(file = model$file_model)
x <- udpipe_annotate(model, x = "Budynek otrzymany od parafii wymaga remontu, a placówka nie otrzymała jeszcze żadnej dotacji.")
x <- as.data.frame(x)
View(x)
@agricolamz
agricolamz / dirichlet_visualisation.R
Created February 23, 2018 07:21
Dirichlet visualisation
devtools::install_github("dkahle/dirichlet")
library(dirichlet)
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)
theme_set(theme_bw())
f <- function(v) {
ddirichlet(v, c(20, 10, 5))
}
mesh <- simplex_mesh(.0025) %>%
@agricolamz
agricolamz / pairwise_count.R
Last active February 23, 2018 07:33
testing pairwise_count from widyr
library(dplyr); library(widyr)
# there are 7 pairs
dat <- data_frame(group = rep(1:7, each = 2),
letter = c("a", "b",
"b", "e",
"a", "c",
"a", "c",
"b", "e",
"b", "e",
@agricolamz
agricolamz / waffle.R
Created February 23, 2018 07:43
Testing waffle package
library(waffle)
# simple waffle -----------------------------------------------------------
parts <- c(plus = 80, times = 30, secret = 20, circle = 10)
waffle(parts, rows=8)
# awsom icons -------------------------------------------------------------
# list of the icon names: http://fontawesome.io/icons/
waffle(parts, rows=8, use_glyph="user-plus")
@agricolamz
agricolamz / Bland-Altman.R
Created February 23, 2018 07:47
Bland-Altman visualisation
# Bland-Altman ------------------------------------------------------------
# about analysis https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4470095/pdf/bm-25-141.pdf
# visulisation from https://sw23993.wordpress.com/2017/05/31/bland-altmantukey-mean-difference-plots-using-ggplot2/
library(tidyverse)
pine_df <- Loblolly
data.frame(sample_n(pine_df, size = nrow(pine_df) * 0.5) %>%
select(height) %>%
arrange(desc(height)),
@agricolamz
agricolamz / sierpinski_triangle.R
Created February 23, 2018 08:29
Sierpinski triangle
# from http://r.prevos.net/sierpinski-triangle/
p <- c(0, 500, 1000)
q <- c(0, 1000, 0)
x11()
par(mar = rep(0, 4))
plot(p, q, col= "red", pch = 15, cex = 1, axes = FALSE)
# Random starting point
x <- sample(0:1000, 1)