Skip to content

Instantly share code, notes, and snippets.

Avatar

Przemysław Biecek pbiecek

View GitHub Profile
View RIO_medale.R
# Pobierz dane
library("XML")
url <- "https://pl.wikipedia.org/wiki/Lista_pa%C5%84stw_%C5%9Bwiata_wed%C5%82ug_liczby_ludno%C5%9Bci"
file<-read_html(url)
tables <-html_nodes(file, "table")
table1 <- html_table(tables[1], fill = TRUE)
table1 <- table1[[1]]
table1 <- table1[table1[,1] != "",]
@pbiecek
pbiecek / shiny_archivist.R
Created Jun 26, 2016
shiny + archivist - examples
View shiny_archivist.R
library(shiny)
library(archivist)
library(ggplot2)
# [a] archivist repo
# create if not exist, or set as default if exists
if (!file.exists("arepo")) {
createLocalRepo("arepo", default = TRUE)
} else {
setLocalRepo("arepo")
View circ.R
library(archivist)
library(circlize)
library(RColorBrewer)
k <- brewer.pal(3,"Set1")
#
# plot
#
movies2014 <- archivist::aread("pbiecek/graphGallery/1f22770967c8b87c1b9028957055eff2")
View wikitrends2.R
wp <- wp_trend(page = c("Andrzej_Sapkowski","Andrzej_Sapkowski","Jacek_Dukaj", "Jacek_Dukaj"),
from = "2013-01-01",
to = today(),
lang = c("pl","en","pl","en"))
head(wp)
## date count lang page rank month title
## 1 2013-01-12 464 pl Andrzej_Sapkowski 1366 201301 Andrzej_Sapkowski
## 2 2013-01-13 538 pl Andrzej_Sapkowski 1366 201301 Andrzej_Sapkowski
## 3 2013-01-10 536 pl Andrzej_Sapkowski 1366 201301 Andrzej_Sapkowski
## 4 2013-01-11 457 pl Andrzej_Sapkowski 1366 201301 Andrzej_Sapkowski
View wikitrends.R
library(wikipediatrend)
wp <- wp_trend(page = c("Aksolotl","Axolotl","The_Witcher", "Wiedźmin"),
from = "2013-01-01",
to = today(),
lang = c("pl","en","en","pl"))
head(wp)
## date count lang page rank month title
## 1 2013-08-26 70 pl Aksolotl -1 201308 Aksolotl
View archivist_3.R
ahistory(tmp)
iris [ff575c261c949d073b2895b05d1097c3]
-> filter(Sepal.Length < 6) [d3696e13d15223c7d0bbccb33cc20a11]
-> lm(Petal.Length ~ Species, data = .) [990861c7c27812ee959f10e5f76fe2c3]
-> summary() [050e41ec3bc40b3004bc6bdd356acae7]
View server.R
library(ggplot2)
library(scales)
library(lubridate)
load("elections1.rda")
shinyServer(function(input, output) {
position <- reactiveValues(x = NULL)
observeEvent(input$plot_hower, {
hower <- input$plot_hower
View wybory2.R
ggplot(elections1, aes(x=daysToElections, y=support)) +
geom_point(aes(shape=source, color=candidate), size=4) +
scale_shape_manual(values=LETTERS) + theme_bw() + xlab("days to elections") + ylab("support (%)") +
scale_y_continuous(limits=c(10,75), breaks=seq(10,70,10)) +
geom_smooth(size=2,aes(color=candidate),se=FALSE, method="lm") +
scale_color_manual(values=c("blue3", "orange3"))
View wybory1.R
> load("elections1.rda")
> head(elections1)
source date candidate support daysToElections
2 CBOS 2015-02-16 Bronisław Komorowski 63.0 -83
3 CBOS 2015-03-02 Bronisław Komorowski 49.0 -69
4 CBOS 2015-03-11 Bronisław Komorowski 52.0 -60
5 CBOS 2015-03-20 Bronisław Komorowski 48.0 -51
6 CBOS 2015-04-22 Bronisław Komorowski 43.0 -18
9 Dobra Opinia 2015-04-10 Bronisław Komorowski 48.3 -30
You can’t perform that action at this time.