Skip to content

> Understanding strip.default & strip.custom

8 messages · Bert Gunter, Patrick Connolly, Duncan Mackay

#
I'm having difficulty following the help for those functions.

My plot has a single conditioning factor with 12 levels.  My
factor.levels in a call to strip.default looks like this:

  factor.levels = expression(Needles~ "::"~alpha -pinene,
                             Stems~ "::"~alpha -pinene,
                             Needles~ "::"~beta -pinene,
                             Stems~ "::"~beta -pinene,
                             Needles~ ":: B?Phellandrene",
                             Stems~ ":: B?Phellandrene",
                             Needles~ ":: Camphene",
                             Stems~ ":: Camphene",
                             Needles~ ":: Myrcene",
                             Stems~ ":: Myrcene",
                             Needles~ ":: Limonene",
                             Stems~ "::Limonene")

Since there is only one factor, which.given must be 1.
Likewise, var.name must be of length 1.

What I can't understand is the argument which.panel.  The help says:

which.panel: vector of integers as long as the number of conditioning
           variables. The contents are indices specifying the current
           levels of each of the conditioning variables (thus, this
           would be unique for each distinct packet).  This is identical
           to the return value of ?which.packet?, which is a more
           accurate name.

So, that must be of length 1 also, according to the first sentence,
but if I set it to 1, I get the first strip label repeated 12 times.
Set it to 2, I get the second one 12 times.  Set it to 1:2, it
attempts to squash 2 strips in the space of 1, labelling the first
one.   I don't understand the second sentence at all.

What do I do to get all 12 in their correct order?

I couldn't find an example remotely like what I'm trying to do.  Are
there any pointers?

TIA
Patrick
#
It's a vector of **length** 1, not **value** 1. In your case it gives
the index (1 to 12) of the level being drawn in the panel, which is
used to draw the strip according to other strip parameters, esp.
style.

You seem to be making this way more difficult than you should.
strip.default is the **function** being used to draw the strips in
each panel. Generally speaking, you should not have to mess with
arguments like which.panel and should probably use strip.custom()
instead.  Do carefully go through the examples in ?strip and ?xyplot.
That may help.

Cheers,
Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
On Mon, Jun 27, 2016 at 7:59 PM, p_connolly <p_connolly at slingshot.co.nz> wrote:
#
Hi Patrick

does this help?

  dat <-
  data.frame(x = rnorm(12*5,0,1),
             y = rnorm(12*5,0,1),
             gp = factor(1:12))
  dat$NS = ifelse(sapply(dat$gp, pmatch,flN, nomatch = 0) > 0, "Needles","Stems")
   dat = dat[order(dat[,"NS"]),]
  dat$GP = factor(1:6)

xyplot(y ~ x|gp, data = dat,
      par.settings = list(strip.background = list(col = "transparent")
                     ),
  strip    = strip.custom(factor.levels = expression(Needles~ "::"~alpha -pinene,
                             Stems~ "::"~alpha -pinene,
                             Needles~ "::"~beta -pinene,
                             Stems~ "::"~beta -pinene,
                             Needles~ ":: B?Phellandrene",
                             Stems~ ":: B?Phellandrene",
                             Needles~ ":: Camphene",
                             Stems~ ":: Camphene",
                             Needles~ ":: Myrcene",
                             Stems~ ":: Myrcene",
                             Needles~ ":: Limonene",
                             Stems~ "::Limonene"),
   par.strip.text = list(cex = 0.65) ))
   
library(latticeExtra)
  useOuterStrips(strip    = strip.custom(factor.levels = expression("::"~alpha -pinene,
                               "::"~beta -pinene,
                               ":: B?Phellandrene",
                               ":: Camphene",
                               ":: Myrcene",
                               ":: Limonene")),
 xyplot(y ~ x|GP*NS, data = dat,
      drop.unused = T,
      par.settings = list(strip.background = list(col = "transparent")
                     ),
     par.strip.text = list(cex = 0.65) )
 ) 
   
If you want to change the order of the factors assign the factor levels to a vector and order accordingly

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of p_connolly
Sent: Tuesday, 28 June 2016 12:59
To: r-help at stat.math.ethz.ch
Subject: [R] > Understanding strip.default & strip.custom

I'm having difficulty following the help for those functions.

My plot has a single conditioning factor with 12 levels.  My
factor.levels in a call to strip.default looks like this:

  factor.levels = expression(Needles~ "::"~alpha -pinene,
                             Stems~ "::"~alpha -pinene,
                             Needles~ "::"~beta -pinene,
                             Stems~ "::"~beta -pinene,
                             Needles~ ":: B?Phellandrene",
                             Stems~ ":: B?Phellandrene",
                             Needles~ ":: Camphene",
                             Stems~ ":: Camphene",
                             Needles~ ":: Myrcene",
                             Stems~ ":: Myrcene",
                             Needles~ ":: Limonene",
                             Stems~ "::Limonene")

Since there is only one factor, which.given must be 1.
Likewise, var.name must be of length 1.

What I can't understand is the argument which.panel.  The help says:

which.panel: vector of integers as long as the number of conditioning
           variables. The contents are indices specifying the current
           levels of each of the conditioning variables (thus, this
           would be unique for each distinct packet).  This is identical
           to the return value of ?which.packet?, which is a more
           accurate name.

So, that must be of length 1 also, according to the first sentence,
but if I set it to 1, I get the first strip label repeated 12 times.
Set it to 2, I get the second one 12 times.  Set it to 1:2, it
attempts to squash 2 strips in the space of 1, labelling the first
one.   I don't understand the second sentence at all.

What do I do to get all 12 in their correct order?

I couldn't find an example remotely like what I'm trying to do.  Are
there any pointers?

TIA
Patrick

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
1 day later
#
On Mon, 27-Jun-2016 at 10:17PM -0700, Bert Gunter wrote:
[...]

|> 
|> You seem to be making this way more difficult than you should.

Though I didn't get any closer to an understanding of which.panel, the
question I asked was simply answered by

panel.custom(factor.levels = <as before>)

Thanks to Duncan Mackay also.
#
Patrick

Have a look at 
https://stat.ethz.ch/pipermail/r-help/2006-August/110621.html
and
https://stat.ethz.ch/pipermail/r-help/2008-June/165279.html

I remember working it out with an example but I cannot remember any of the
details

Regards

Duncan


-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Patrick
Connolly
Sent: Wednesday, 29 June 2016 18:30
To: Bert Gunter
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] > Understanding strip.default & strip.custom
On Mon, 27-Jun-2016 at 10:17PM -0700, Bert Gunter wrote:
[...]

|> 
|> You seem to be making this way more difficult than you should.

Though I didn't get any closer to an understanding of which.panel, the
question I asked was simply answered by

panel.custom(factor.levels = <as before>)

Thanks to Duncan Mackay also.
#
Did you mean: strip.custom(factor.levels...)  ?

(I know of no "panel.custom()" function)


-- Bert
Bert Gunter

"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Jun 29, 2016 at 1:29 AM, Patrick Connolly
<p_connolly at slingshot.co.nz> wrote:
#
On Wed, 29-Jun-2016 at 07:57AM -0700, Bert Gunter wrote:
|> Did you mean: strip.custom(factor.levels...)  ?
|> 

Aaamm yes.  Must stop doing this stuff so late.............


|> (I know of no "panel.custom()" function)
|> 
|> 
|> -- Bert
|> Bert Gunter
|> 
|> "The trouble with having an open mind is that people keep coming along
|> and sticking things into it."
|> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
|> 
|> 
|> On Wed, Jun 29, 2016 at 1:29 AM, Patrick Connolly
|> <p_connolly at slingshot.co.nz> wrote:
|> > On Mon, 27-Jun-2016 at 10:17PM -0700, Bert Gunter wrote:
|> >
|> > [...]
|> >
|> > |>
|> > |> You seem to be making this way more difficult than you should.
|> >
|> > Though I didn't get any closer to an understanding of which.panel, the
|> > question I asked was simply answered by
|> >
|> > panel.custom(factor.levels = <as before>)
|> >
|> > Thanks to Duncan Mackay also.
|> >
|> > --
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> >    ___    Patrick Connolly
|> >  {~._.~}                   Great minds discuss ideas
|> >  _( Y )_                 Average minds discuss events
|> > (:_~*~_:)                  Small minds discuss people
|> >  (_)-(_)                              ..... Eleanor Roosevelt
|> >
|> > ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
#
On Wed, 29-Jun-2016 at 10:15PM +1000, Duncan Mackay wrote:
|> Patrick
|> 
|> Have a look at 
|> https://stat.ethz.ch/pipermail/r-help/2006-August/110621.html
|> and
|> https://stat.ethz.ch/pipermail/r-help/2008-June/165279.html
|> 
|> I remember working it out with an example but I cannot remember any of the
|> details

It would be amazing for anyone to remember those details. ;-)



|> 
|> Regards
|> 
|> Duncan
|> 
|> 
|> -----Original Message-----
|> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Patrick
|> Connolly
|> Sent: Wednesday, 29 June 2016 18:30
|> To: Bert Gunter
|> Cc: r-help at stat.math.ethz.ch
|> Subject: Re: [R] > Understanding strip.default & strip.custom
|>
|> On Mon, 27-Jun-2016 at 10:17PM -0700, Bert Gunter wrote:
|> 
|> [...]
|> 
|> |> 
|> |> You seem to be making this way more difficult than you should.
|> 
|> Though I didn't get any closer to an understanding of which.panel, the
|> question I asked was simply answered by
|> 
|> panel.custom(factor.levels = <as before>)
|> 
|> Thanks to Duncan Mackay also.
|> 
|> -- 
|> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
|>    ___    Patrick Connolly   
|>  {~._.~}                   Great minds discuss ideas    
|>  _( Y )_  	         Average minds discuss events 
|> (:_~*~_:)                  Small minds discuss people  
|>  (_)-(_)  	                      ..... Eleanor Roosevelt
|> 	  
|> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
|> 
|> ______________________________________________
|> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
|> 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.