[R] Changing strip text

Peter Ehlers ehlers at ucalgary.ca
Tue Jun 19 19:16:48 CEST 2012


On 2012-06-18 20:35, Duncan Mackay wrote:
> Hi Julie
>
> Try
>
> strip.custom(factor.levels = paste("Treat", c("0","2","4","8","16"), sep = " ")

That won't necessarily work; it depends on what type 'Treat' is.
I suspect that it's not a factor. Here's an example using the
iris data:

First, let's augment the data with a variable 'spec' that we'll
use as a conditioning variable.

   dat <- transform(iris, spec = rep(0:2, each=50))

Now compare two plots:

# Plot 1: ('spec' is not a factor)

   xyplot(Sepal.Length ~ Sepal.Width | spec, data = dat,
    strip = strip.custom(
      factor.levels = paste(
         "Treat", c("0","2","4"), sep = " ")))

# Plot 2: ('Species' is a factor)

   xyplot(Sepal.Length ~ Sepal.Width | Species, data = dat,
    strip = strip.custom(
      factor.levels = paste(
         "Treat", c("0","2","4"), sep = " ")))


Peter Ehlers

> i.e
> xyplot(log(pfuml)~Transfer|Treat,groups=Pop,ylab="Log10 Pfu/ml",as.table=T,
>                   type="a",
>                   auto.key=list(space="right",points=F,lines=T) ),
>                        strip=strip.custom(factor.levels =
> paste("Treat", c("0","2","4","8","16"), sep = " "),par.strip.text =
> list(cex = 0.85) )
>                   )
>
> Should work but without an example ...
> I have added par.strip.text in case the size is not right for you as
> an example for future use
>
> Regards
>
> Duncan
>
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2351
> Email: home: mackay at northnet.com.au
>
> At 03:02 19/06/2012, you wrote:
>> I'm trying to create a 5-panel xyplot with each strip labelled by
>> treatment. The code is as follows:
>>
>> xyplot(log(pfuml)~Transfer|Treat,groups=Pop,ylab="Log10 Pfu/ml",as.table=T,
>>                  type="a",
>>                  auto.key=
>>                  list(space="right",points=F,lines=T))
>>
>>
>>
>> I've tried:
>>
>> strip=strip.custom(factor.levels=c("0","2","4","8","16")
>>
>> But it's not working, I still only get "Treat" printed on each
>> strip. Any ideas?
>>
>> Thank you,
>>
>> Julie
>>
>>



More information about the R-help mailing list