truncHist: Truncated Histograms

Description Usage Arguments Details Author(s) See Also Examples

View source: R/truncHist.R

Description

Produces a truncated histogram.

Usage

1
truncHist(x, xmin = NULL, xmax = NULL, trim = 0.025, main = NULL, xlab = "x", ...)

Arguments

x

Vector of numerical observations.

xmin

Minimum numerical value to be shown in graph.

xmax

Maximum numerical value to be shown in graph.

trim

The fraction (0 to 0.5) of observations to be trimmed from each end of x before the histogram is constructed.

main

An overall title for the histogram.

xlab

A title for the x-axis.

...

Optional arguments to hist.

Details

truncHist may be useful if data contain some extreme outliers.

Author(s)

Steven T. Garren, James Madison University, Harrisonburg, Virginia, USA

See Also

hist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
x1 = sort(rnorm(1000)) ;   c( head(x1), tail(x1)) 

x2 = sort(rnorm(1000)) ;   c( head(x2), tail(x2)) 

y1 = sort(rcauchy(1000)) ; c( head(y1), tail(y1)) 

y2 = sort(rcauchy(1000)) ; c( head(y2), tail(y2)) 

par( mfrow=c(2,2) )
truncHist(x1, main="Normal data; first simulation",  xlab="x1")
truncHist(x2, main="Normal data; second simulation", xlab="x2")
truncHist(y1, main="Cauchy data; first simulation",  xlab="y1")
truncHist(y2, main="Cauchy data; second simulation", xlab="y2")
par( mfrow=c(1,1) )

Example output

 [1] -3.730393 -3.010415 -3.003349 -2.825386 -2.796845 -2.722784  2.504613
 [8]  2.512853  2.634455  2.689028  2.746614  2.989053
 [1] -3.717358 -3.159025 -2.952468 -2.804145 -2.615060 -2.588756  2.414287
 [8]  2.549705  2.642174  2.666765  3.118258  3.671325
 [1] -110.72882  -97.46807  -94.52175  -65.74617  -48.57877  -32.07756
 [7]   42.30049   42.34829   83.49353   84.92954  132.74905  639.64928
 [1] -776.74122 -424.24072 -271.53434 -116.48512 -105.95380  -71.35200
 [7]   55.87423   59.03303   59.84341  115.05525  141.71410  290.09333

jmuOutlier documentation built on Aug. 6, 2019, 1:03 a.m.