-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.r
More file actions
executable file
·60 lines (43 loc) · 1.37 KB
/
example.r
File metadata and controls
executable file
·60 lines (43 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/Rscript
source("plot.r")
doConfidence <- function() {
numPoints <- 10
x <- rnorm(numPoints)
y <- rnorm(numPoints)
plotWithConfidence(x, y, abs(y/10.0), pdfFile="conf.pdf")
}
doConfidenceCategorial <- function() {
x <- c("Bier", "Mate", "water", "Weizen")
y <- rnorm(length(x))
plotWithConfidence(x, y, abs(y/10.0), pdfFile="confCategorial.pdf", xDataIsCategorial=TRUE)
}
doConfidenceCategorialFromFile <- function(name) {
a <- read.table(name)
plotWithConfidence(t(a[1]), t(a[2]), t(a[3]), pdfFile="confCategorial2.pdf", xDataIsCategorial=TRUE)
}
doBoxPlot <- function() {
numPoints <- 10000
x <- rnorm(numPoints)
y <- rnorm(numPoints)
plotBoxes(x, y, pdfFile="box.pdf")
}
doConfidenceContinous <- function() {
x1 <- seq(0,10,0.01)
x <- x1
for (i in 1:31) {
x <- c(x,x1)
}
numPoints <- length(x)
y <- x*x + rnorm(numPoints)
outMean <- tapply(y, x, mean)
outSD <- tapply(y, x, sd)
out <- data.frame(x = names(outMean), mean = outMean, sd = outSD, row.names = NULL)
confLevel <- 0.99
numReplications <- 32
plotWithConfidenceContinous(x1, out$mean, 10.0 * qnorm(1.0 - (1.0 - confLevel)/2.0) * out$sd/sqrt(numReplications), pdfFile = "confContinous.pdf")
}
doBoxPlot()
doConfidence()
doConfidenceCategorial()
doConfidenceContinous()
doConfidenceCategorialFromFile("result")