
Last chance! 50% off unlimited learning
Sale ends in
This R function provides a convenient way to visualize the distribution of grouped numerical data.
ehplot(data, groups, intervals=50, offset=0.1, log=FALSE,
median=TRUE, box=FALSE, boxborder="grey50",
xlab="groups", ylab="values", col="black",
add=FALSE, sort=TRUE, ...)
Vector of numerical data.
Vector of group names which should have the same length as data.
The data is splitted into a certain number of intervals. If data points are in the same interval they are drawn side-by-side.
x-distance between two data points at the same interval.
Logarithmic display
To show the median of each group. NAs in data are not considered for calculating the medians.
To underlay a boxplot.
The color of the boxplot if a boxplot is drawn.
x-axis label
y-axis label
vector of colors for the datapoints. (recycled as necessary).
add this plot to an existing one (i.e. do not call plot.new).
normally, the groups are sorted by name. To keep the order as provided in the groups-vector, set this to FALSE
additional plot-parameters will be passed to the plot-function
# NOT RUN {
data(iris)
ehplot(iris$Sepal.Length, iris$Species, intervals=20, cex=1.8, pch=20)
ehplot(iris$Sepal.Width, iris$Species, intervals=20, box=TRUE, median=FALSE)
ehplot(iris$Petal.Length, iris$Species, pch=17, col="red", log=TRUE)
ehplot(iris$Petal.Length, iris$Species, offset=0.06, pch=as.numeric(iris$Species))
# Groups don't have to be presorted:
rnd <- sample(150)
plen <- iris$Petal.Length[rnd]
pwid <- abs(rnorm(150, 1.2))
spec <- iris$Species[rnd]
ehplot(plen, spec, pch=19, cex=pwid, col=rainbow(3, alpha=0.6)[as.numeric(spec)])
# }
Run the code above in your browser using DataLab