On Sep 15, 2012, at 7:15 PM, mcg wrote:

> Hello R-users,
> 
> I would like to use subscript in chemical formulas for the different 
> treatments in a boxplot.
> Fot title, xlab and ylab sub- and superscript is no problem, but for the 
> different treatments of the following example I cannot get subscript.
> 
> Example:
> weight <-  c(6,5,7,2,7,3,9,4,2,7,8,9,2,3,4,5)
> treatments <- as.factor(rep(c('Control', 'P2O5','K2SO4','CaSO4'),4))
> data <- data.frame(treatments,weight)
> boxplot(data$weight~data$treatments)
> 
> If I apply expression(P[2]...) I get  "unimplemented type 'expression' in 
> 'HashTableSetup' ".
> If there is a solution for this in base graphics or ggplot please let me know.
> 

?plotmath
 boxplot(data$weight~data$treatments, xaxt="n")
 axis(1, 1:4, labels=expression(Control, P[2]*O[5], K[2]*SO[4], CaSO[4]) )

I will admit that the need for the "*"'s was not apparent to me until I used 
the initial example as a starting point and made incremental changes until I 
gotsuccess. So I am not suggesting that RTM should have been enough.

-- 
David Winsemius, MD
Alameda, CA, USA

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to