[R] Lattice: Feature Request

Deepayan Sarkar deepayan.sarkar at gmail.com
Sun Mar 13 10:04:57 CET 2011


On Sat, Mar 12, 2011 at 1:30 AM, Jim Price <price_ja at hotmail.com> wrote:
> Thanks Peter.
>
> This is true, but consider this continuation of my example (which is
> probably what I should have written originally):
>
>
> my.opts <- list(default.args = list(
>                       as.table = TRUE,
>                                    between = list(x = 0.2, y = 0.2),
>                       scales = list(alternating = 1, tck = c(1, 0), col =
> 'black') # Illustrative, doesn't do anything
>                ))
>
>
> oldopts <- lattice.options(my.opts)
>
> useOuterStrips(xyplot(
>                      resp ~ time | subject * var,
>                      data = temp
>                      ))
>
> lattice.options(oldopts)
>
>
> If the scales option worked like as.table, aspect, etc, then I wouldn't need
> to use a default.scales call per xyplot. Just trying to remove some typing
> from each call that I make.

Your wish is reasonable, but note that there are two kinds of default
arguments handled by lattice.options(): those that are common for all
functions (like "as.table" and "between") and those that are
function-specific, like "panel.xyplot", "panel.bwplot", etc. Adding a
new default of the second kind involves a lot more work (both
implementation and maintenance), and I would be reluctant to do so
unless there is a really good reason. I'm more open to additions of
the first kind.

In this particular case, "default.scales" is really function-specific.
On the other hand, only a few functions (e.g., bwplot, cloud, splom)
have a default value other than list(), so having a global default
(overridden in those few cases) shouldn't be too bad. Of course then
it will not be possible to have, say, an xyplot-specific change,
because the change will also affect densityplot(), histogram(), etc.
If that seems reasonable, please go ahead and send me a patch.

-Deepayan


> Jim.
>
>
>
> Peter Ehlers wrote:
>>
>> On 2011-03-10 15:07, Jim Price wrote:
>> New feature not needed. You'll notice that the 'Details'
>> section of ?xyplot says, regarding lattice.options:
>>
>>    Default values can be set in this manner for the following
>>    arguments: as.table, aspect, between, page, main, sub,
>>    par.strip.text, layout, skip and strip.
>>
>> No mention of 'scales'. But xyplot has an argument
>> 'default.scales' which you can set globally:
>>
>>   def.scal <- list(alternating = 1, tck = c(1, 0))
>>
>> and then add this
>>
>>   default.scales = def.scal
>>
>> to the arguments in your xyplot call.
>>
>>
>> Peter Ehlers



More information about the R-help mailing list