Wrapper for base R density function that removes outliers and computes 'reasonable' bandwidth and x and y limits. Used for ctsem density plots.
ctDensity(x, bw = "auto", plot = FALSE, ...)
numeric vector on which to compute density.
either 'auto' or a numeric indicating bandwidth.
logical to indicate whether or not to plot the output.
Further args to density.
# NOT RUN {
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))
# }
Run the code above in your browser using DataLab