[R] boxplot - how to supress groups with low counts
Uwe Ligges
ligges at statistik.tu-dortmund.de
Fri Jan 28 15:09:01 CET 2011
On 28.01.2011 14:21, pdb wrote:
>
> In a boxplot - how can I prevent groups where the number of cases is less
> than a set threshold from being plotted.
>
> set.seed(42)
> DF<- data.frame(type=sample(LETTERS[1:5], 100, replace=TRUE),
> cost=rnorm(100))
> count<- boxplot(cost ~ type, data=DF, plot = 0)
> count$n
>
> ## how to only include plots where count$n> 18
> boxplot(cost ~ type, data=DF)
>
> Thanks in advance for any solutions.
set.seed(42)
DF <- data.frame(type = sample(LETTERS[1:5], 100, replace=TRUE),
cost = rnorm(100))
count <- boxplot(cost ~ type, data=DF, plot = 0)
for(i in c(1,3)) count[[i]] <- count[[i]][,count$n > 18]
for(i in c(6,2)) count[[i]] <- count[[i]][count$n > 18]
bxp(count)
Uwe Ligges
More information about the R-help
mailing list