Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
Related Setup: https://gist.github.com/hofmannsven/6814278
Related Pro Tips: https://ochronus.com/git-tips-from-the-trenches/
library(ggplot2) | |
# library(cowplot) | |
library(dplyr) | |
logist <- function(x){ | |
y = exp(x) / (1 + exp(x)) | |
} | |
p1 <- ggplot(data_frame()) |
# Plot path diagram with {DiagrammeR} | |
data(Wage, package = "ISLR") #load data | |
lm_wage <- lm(wage ~ health + age + health:age, data = Wage) # run linear model | |
summary(lm_wage) | |
library(semPlot) # plot path diagram with {semPlot} | |
semPaths(lm_wage, whatLabel = "est", vsize.man = 16, edge.label.cex=0.6) |
############################################################################### | |
### Beispiel-Analyse des Datensatzes "tips" | |
### von Sebastian Sauer, letztes Update: 2016-01-18 | |
### Zugang zu den Daten: Der Datensatz findet sich im Paket "reshape2" | |
############################################################################### | |
# Hinweis: Es ist ganz normal, Syntax/Befehle nachzuschlagen :) | |
# Eine Möglichkeit dazu ist mit help(Befehl), z.B. | |
help(library) # oder mit google :) |
library(dplyr) | |
data(Wage, package = "ISLR") | |
Wage %>% | |
mutate(wage_f = ntile(wage, 2)) %>% # bin it | |
group_by(wage_f, health, race) %>% | |
summarise(count = n()) %>% | |
ggplot(aes(x = factor(wage_f), y = count, fill = race)) + | |
geom_bar(stat = "identity") + |
#Barplots with exact numbers | |
data(tips, package = "reshape2") # load some data | |
library(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
tips %>% |
SLIDES := $(patsubst %.md,%.md.slides.pdf,$(wildcard *.md)) | |
HANDOUTS := $(patsubst %.md,%.md.handout.pdf,$(wildcard *.md)) | |
all : $(SLIDES) $(HANDOUTS) | |
%.md.slides.pdf : %.md | |
pandoc $^ -t beamer --slide-level 2 -o $@ | |
%.md.handout.pdf : %.md | |
pandoc $^ -t beamer --slide-level 2 -V handout -o $@ |
# plot normal distribution with ggplot2, simply | |
library(cowplot) | |
p1 <- ggplot(data = data.frame(x = c(-3, 3)), aes(x)) + | |
stat_function(fun = dnorm, n = 101, args = list(mean = 0, sd = 1)) + ylab("") + | |
scale_y_continuous(breaks = NULL) | |
p1 |
# Exam grading, as a convenience function for teachers | |
# Sebastian Sauer | |
# Stand: 2016-05-20 | |
# need to be installed upfront with "install.packages()" | |
library(ggplot2) | |
library(car) | |
library(tidyr) |
# normal distribution with serveral shaded areas | |
library(ggplot2) | |
library(dplyr) | |
mean.1 <-0 | |
sd.1 <- 1 | |
zstart <- 2 | |
zend <- 3 | |
zcritical <- 1.65 |