[R] locating boxplot in bwplot (lattice)

Peter Ehlers ehlers at ucalgary.ca
Sun Feb 24 21:17:32 CET 2013


On 2013-02-24 03:50, Elaine Kuo wrote:
> Hello
>
> Thank you for the advice on vector.
> I found a previous mail on this issue and pasted it below.
>
> Now here comes a different scenario.
> I have more than 20 boxplots and just wanted the first two from the left to
> be red and the rest to be blue.
> Please kindly advise how to code the color without writing the color names
> 18 times.
> Thanks again.
>
> Elaine

[...snip...]

I haven't followed this thread, but is there some reason why you can't
just use rep()?

Example (from the help page for bwplot):

  mycol <- rep( c("red", "blue"), c(2, 6) )
  bwplot(voice.part ~ height, data = singer, fill = mycol)

Peter Ehlers



More information about the R-help mailing list