ctDensity: ctDensity

View source: R/ctsemUtils.R

ctDensityR Documentation

ctDensity

Description

Wrapper for base R density function that removes outliers and computes 'reasonable' bandwidth and x and y limits. Used for ctsem density plots.

Usage

ctDensity(x, bw = "auto", plot = FALSE, ...)

Arguments

x

numeric vector on which to compute density.

bw

either 'auto' or a numeric indicating bandwidth.

plot

logical to indicate whether or not to plot the output.

...

Further args to density.

Examples

y <- ctDensity(exp(rnorm(80)))
plot(y$density,xlim=y$xlim,ylim=y$ylim)

#### Compare to base defaults:
par(mfrow=c(1,2))
y=exp(rnorm(10000))
ctdens<-ctDensity(y)
plot(ctdens$density, ylim=ctdens$ylim,xlim=ctdens$xlim)
plot(density(y))

ctsem documentation built on Sept. 11, 2024, 9:06 p.m.