[R-sig-eco] omit levels from boxplots

Jarrett Byrnes byrnes at nceas.ucsb.edu
Thu Jan 6 18:16:19 CET 2011


Ah, so, you have factors that are no longer present in the data.  I use a quick function I wrote called purgef to get rid of zombie factors.

purgef<-function(x) lapply(x, function(x) x[drop = TRUE])


So, here, before your boxplot

dat$ageclass <- purgef(dat$ageclass)

On Jan 6, 2011, at 9:09 AM, Howe, Eric (MNR) wrote:

> Good day list members,
> 
> 
> 
> I was wondering if anyone knows a way to omit specific columns or anova
> cells from boxplots.  
> 
> 
> 
> E.g. I produce a boxplot as:
> 
> 
> 
>> boxplot(y ~ ageclass + sex,data=dat)
> 
> 
> 
> where ageclass has 4 levels (including 1-year-old), and sex has 2
> levels, but the only males included in the analysis are one-year-olds. 
> 
> The resulting boxplot illustrates differences among age classes of
> females, and between male and female one-year-olds.
> 
> However, it has 3 blank columns, corresponding to subadult, young adult,
> and mature age classes of males.  
> 
> I'd like to exclude those blank columns from the figure.
> 
> 
> 
> Thanks in advance,
> 
> 
> 
> Eric
> 
> 
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology



More information about the R-sig-ecology mailing list