The R Project SVN R

Rev

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

Rev 27447 Rev 27713
Line 149... Line 149...
149
 
149
 
150
\examples{
150
\examples{
151
data(islands)
151
data(islands)
152
op <- par(mfrow=c(2, 2))
152
op <- par(mfrow=c(2, 2))
153
hist(islands)
153
hist(islands)
154
str(hist(islands, col="gray", labels = TRUE))
154
utils::str(hist(islands, col="gray", labels = TRUE))
155
 
155
 
156
hist(sqrt(islands), br = 12, col="lightblue", border="pink")
156
hist(sqrt(islands), br = 12, col="lightblue", border="pink")
157
##-- For non-equidistant breaks, counts should NOT be graphed unscaled:
157
##-- For non-equidistant breaks, counts should NOT be graphed unscaled:
158
r <- hist(sqrt(islands), br = c(4*0:5, 10*3:5, 70, 100, 140), col='blue1')
158
r <- hist(sqrt(islands), br = c(4*0:5, 10*3:5, 70, 100, 140), col='blue1')
159
text(r$mids, r$density, r$counts, adj=c(.5, -.5), col='blue3')
159
text(r$mids, r$density, r$counts, adj=c(.5, -.5), col='blue3')
160
sapply(r[2:3], sum)
160
sapply(r[2:3], sum)
161
sum(r$density * diff(r$breaks)) # == 1
161
sum(r$density * diff(r$breaks)) # == 1
162
lines(r, lty = 3, border = "purple") # -> lines.histogram(*)
162
lines(r, lty = 3, border = "purple") # -> lines.histogram(*)
163
par(op)
163
par(op)
164
 
164
 
165
str(hist(islands, plot= FALSE))        #-> 5  breaks
-
 
166
str(hist(islands, br=12, plot= FALSE)) #-> 10 (~= 12) breaks
165
utils::str(hist(islands, br=12, plot= FALSE)) #-> 10 (~= 12) breaks
167
str(hist(islands, br=c(12,20,36,80,200,1000,17000), plot = FALSE))
166
utils::str(hist(islands, br=c(12,20,36,80,200,1000,17000), plot = FALSE))
-
 
167
 
168
    hist(islands, br=c(12,20,36,80,200,1000,17000), freq = TRUE,
168
hist(islands, br=c(12,20,36,80,200,1000,17000), freq = TRUE,
169
         main = "WRONG histogram") # and warning
169
     main = "WRONG histogram") # and warning
170
}
170
}
171
\keyword{dplot}
171
\keyword{dplot}
172
\keyword{hplot}
172
\keyword{hplot}
173
\keyword{distribution}
173
\keyword{distribution}