Learn R Programming

aplpack (version 1.3.3)

slider.hist: interactive histogram and density traces

Description

The functions slider.hist and slider.density compute histograms and density traces whereas some parameter are controlled by sliders.

slider.hist computes a histogram; the number of classes is defined by a slider.

slider.density computes a density trace; width and type of the kernel are defined by sliders.

Usage

slider.hist(x, panel, ...)
  slider.density(x, panel, ...)

Arguments

x

data set to be used for plotting

panel

function constructing additional graphical elements to the plot

additional (graphics) parameters which are passed to the invoked high level plotting function

Value

a message about the usage

Details

slider.hist draws a histogram of the data set x by calling hist and opens a Tcl/Tk widget with one slider. The slider defines the number of classes of the histogram. Changing the slider results in redrawing of the plot. For further details see the help page of hist. rug is used as the default panel function.

slider.density draws a density trace of the data set x by plot(density(...)) and opens a Tcl/Tk-widget with two sliders. The first slider defines the width of the density trace and the second one the kernel function: "1-gaussian", "2-epanechnikov", "3-rectangular", "4-triangular","5-biweight", "6-cosine", "7-optcosine" Changing one of the sliders results in a redrawing of the plot. For further details see the help page of density. rug is used as the default panel function.

References

~~

See Also

hist, slider

Examples

Run this code
# NOT RUN {
## This example cannot be run by examples() but should be work in an interactive R session
  slider.hist(log(islands))
# }
# NOT RUN {
## This example cannot be run by examples() but should be work in an interactive R session
slider.density(rivers,xlab="rivers",col="red")
# }
# NOT RUN {
## This example cannot be run by examples() but should be work in an interactive R session
slider.density(log(rivers),xlab="rivers",col="red",
  panel=function(x){
    xx<-seq(min(x),max(x),length=100)
    yy<-dnorm(xx,mean(x),sd(x))
    lines(xx,yy)
    rug(x)
    print(summary(yy))
  }
)
# }

Run the code above in your browser using DataLab