Skip to content

Instantly share code, notes, and snippets.

View pbiecek's full-sized avatar

Przemysław Biecek pbiecek

View GitHub Profile
@pbiecek
pbiecek / HEplot
Last active August 29, 2015 14:15
library(PISA2012lite)
pol <- student2012[student2012$CNT == 'Poland',]
model <- lm(cbind(PV1MATH, PV1READ, PV1SCIE)~ST28Q01+ST04Q01, pol)
# jeżeli nie jest zainstalowany to
# install.packages("heplots")
library(heplots)
heplot(model, size="effect.size", las=1, term.labels=FALSE)
# install_github("amplab-extras/SparkR-pkg",
# subdir="pkg")
library(SparkR)
# you need to have a properly configured Spark installation
sc <- sparkR.init()
# read data from local disk
linesRDD <- textFile(sc, "data.txt")
## server.r
library(ggplot2)
library(scales)
library(Cairo)
library(ggthemes)
library(shiny)
load("dzch.rda")
zielonaChoinka <- function() {
## ui.R
library(shiny)
shinyUI(fluidPage(
textInput(inputId = "imie",
label = "Zaznacz imiona",
value = ""),
plotOutput("choinka", width=720, height=720)
)
)
@pbiecek
pbiecek / cl2
Created January 28, 2015 21:36
heatmap(as.matrix(country_jumper_points))
pheatmap(country_jumper_points,
main="Where they've got points")
pheatmap(country_jumper_points, border="white",
color = brewer.pal(9,"Blues"),
main="Where they've got points")
@pbiecek
pbiecek / cl1
Created January 28, 2015 21:35
library(pheatmap)
library(tidyr)
library(RColorBrewer)
library(SmarterPoland)
country_jumper_points <- skiJumps2013 %>%
mutate(jumper = paste(jumperSurname, jumperName)) %>%
group_by(jumper, compName) %>%
summarise(max.points = sum(classPoints, na.rm=TRUE)) %>%
group_by(jumper) %>%
setwd("~/Dropbox/Projekt Akcelerometr/")
library(ggplot2)
library(lubridate)
read.table("2015-01-20_09-50-28.csv", h=T, sep=",") -> marsz
read.table("2015-01-26_12-32-02.csv", h=T, sep=",") -> schody
read.table("2015-01-26_20-43-38.csv", h=T, sep=",") -> skoki
marsz$loggingTime <- ymd_hms(marsz$loggingTime)
wynik_matematyka$Kolor <- ifelse(wynik_matematyka$CNT=='Poland','red','black')
OECD_mean <- mean(wynik_matematyka$PV)
### wykresy
ggplot(data = wynik_matematyka,
aes(x=reorder(CNT,PV),
y=PV)) +
geom_errorbar(aes(ymin=PV-z_alpha*SE,
ymax=PV+z_alpha*SE)) +
geom_point(colour='red') +
theme_bw() +
wynik_matematyka <- badanie %>%
do(data.frame(PV1 = svymean(~PV1MATH,design = .$schemat),
PV2 = svymean(~PV2MATH,design = .$schemat),
PV3 = svymean(~PV3MATH,design = .$schemat),
PV4 = svymean(~PV4MATH,design = .$schemat),
PV5 = svymean(~PV5MATH,design = .$schemat))) %>%
ungroup() %>%
mutate(CNT = badanie$CNT) %>%
gather(Stat,Value,-CNT) %>%
separate(Stat,c('PV','STAT'),sep='\\.') %>%
### przedział ufności
alpha <- 0.05
z_alpha <- qnorm(1-alpha/2)
wynik$Kolor <- ifelse(wynik$CNT=='Poland','red','black')
### wykresy
ggplot(data = wynik,
aes(x=reorder(CNT,PV1MATH),
y=PV1MATH)) +
geom_errorbar(aes(ymin=PV1MATH-z_alpha*SE,
ymax=PV1MATH+z_alpha*SE)) +