The R Project SVN R

Rev

Rev 61160 | Rev 64214 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 61160 Rev 61168
Line 84... Line 84...
84
Fn(x)  # returns the percentiles for x
84
Fn(x)  # returns the percentiles for x
85
tt <- seq(-2, 2, by = 0.1)
85
tt <- seq(-2, 2, by = 0.1)
86
12 * Fn(tt) # Fn is a 'simple' function {with values k/12}
86
12 * Fn(tt) # Fn is a 'simple' function {with values k/12}
87
summary(Fn)
87
summary(Fn)
88
##--> see below for graphics
88
##--> see below for graphics
89
knots(Fn)# the unique data values {12 of them if there were no ties}
89
knots(Fn)  # the unique data values {12 of them if there were no ties}
90
 
90
 
91
y <- round(rnorm(12), 1); y[3] <- y[1]
91
y <- round(rnorm(12), 1); y[3] <- y[1]
92
Fn12 <- ecdf(y)
92
Fn12 <- ecdf(y)
93
Fn12
93
Fn12
94
knots(Fn12) # unique values (always less than 12!)
94
knots(Fn12) # unique values (always less than 12!)
Line 102... Line 102...
102
stopifnot(all.equal(quantile(Fn12), quantile(y)))
102
stopifnot(all.equal(quantile(Fn12), quantile(y)))
103
 
103
 
104
###----------------- Plotting --------------------------
104
###----------------- Plotting --------------------------
105
require(graphics)
105
require(graphics)
106
 
106
 
107
op <- par(mfrow = c(3,1), mgp = c(1.5, 0.8,0), mar =  .1+c(3,3,2,1))
107
op <- par(mfrow = c(3, 1), mgp = c(1.5, 0.8, 0), mar =  .1+c(3,3,2,1))
108
 
108
 
109
F10 <- ecdf(rnorm(10))
109
F10 <- ecdf(rnorm(10))
110
summary(F10)
110
summary(F10)
111
 
111
 
112
plot(F10)
112
plot(F10)
113
plot(F10, verticals = TRUE, do.points = FALSE)
113
plot(F10, verticals = TRUE, do.points = FALSE)
114
 
114
 
115
plot(Fn12 , lwd = 2) ; mtext("lwd = 2", adj = 1)
115
plot(Fn12 , lwd = 2) ; mtext("lwd = 2", adj = 1)
116
xx <- unique(sort(c(seq(-3, 2, length = 201), knots(Fn12))))
116
xx <- unique(sort(c(seq(-3, 2, length = 201), knots(Fn12))))
117
lines(xx, Fn12(xx), col = 'blue')
117
lines(xx, Fn12(xx), col = "blue")
118
abline(v = knots(Fn12), lty = 2,col = 'gray70')
118
abline(v = knots(Fn12), lty = 2, col = "gray70")
119
 
119
 
120
plot(xx, Fn12(xx), type = 'o', cex = .1) #- plot.default {ugly}
120
plot(xx, Fn12(xx), type = "o", cex = .1)  #- plot.default {ugly}
121
plot(Fn12, col.hor = 'red', add =  TRUE)  #- plot method
121
plot(Fn12, col.hor = "red", add =  TRUE)  #- plot method
122
abline(v = knots(Fn12),lty = 2, col = 'gray70')
122
abline(v = knots(Fn12), lty = 2, col = "gray70")
123
## luxury plot
123
## luxury plot
124
plot(Fn12, verticals = TRUE, col.points = 'blue',
124
plot(Fn12, verticals = TRUE, col.points = "blue",
125
     col.hor = 'red', col.vert = 'bisque')
125
     col.hor = "red", col.vert = "bisque")
126
 
126
 
127
##-- this works too (automatic call to  ecdf(.)):
127
##-- this works too (automatic call to  ecdf(.)):
128
plot.ecdf(rnorm(24))
128
plot.ecdf(rnorm(24))
129
title("via  simple  plot.ecdf(x)", adj = 1)
129
title("via  simple  plot.ecdf(x)", adj = 1)
130
 
130