[R] update'ing trellis object
David Winsemius
dwinsemius at comcast.net
Mon Oct 5 01:23:29 CEST 2009
I wonder if you noticed that you had managed to create a "fig" object
that has two "inside" lists by specifying first a key "list" which
required a legend list, and then specifying a "legend" list that also
had a key function? The solution to your specific request by Kortschak
"nulled-out" the second of those.
--
David
On Oct 3, 2009, at 10:35 PM, David Winsemius wrote:
>
> On Oct 3, 2009, at 7:05 PM, Sebastian P. Luque wrote:
>
>> Hi,
>>
>> I thought the following would only remove the legend element of a
>> trellis object, but it actually removes both the legend and key
>> elements:
>>
>> ---<--------------------cut here---------------
>> start------------------->---
>> fig <- xyplot(Sepal.Length ~ Petal.Length, groups=Species, data=iris,
>> key=list(x=1, y=0.02, corner=c(1, 0), size=3, between=1,
>> text=list(levels(iris$Species))),
>> legend=list(inside=list(fun="draw.key", x=0, y=1,
>> corner=c(0, 1),
>> args=list(key=list(text=list("a)",
>> cex=1.5)),
>> draw=FALSE))))
>> update(fig, legend=NULL)
>> ---<--------------------cut here---------------
>> end--------------------->---
>>
>> Is this the right way to remove an element from the object, using
>> update.trellis()? Thanks.
>>
> It probably depends on the element. In the case of "key", it is a
> descendant of the legend list so when you make legend NULL you are
> wiping out all of its descendants as well:
> > str(fig)
> List of 43
> snipped a few lines
> $ legend :List of 2
> ..$ inside:List of 5
> .. ..$ fun : chr "draw.key"
> .. ..$ args :List of 2
> .. .. ..$ key :List of 6
> .. .. .. ..$ x : num 1
> .. .. .. ..$ y : num 0.02
> .. .. .. ..$ corner : num [1:2] 1 0
> .. .. .. ..$ size : num 3
> .. .. .. ..$ between: num 1
> .. .. .. ..$ text :List of 1
> .. .. .. .. ..$ : chr [1:3] "setosa" "versicolor" "virginica"
> .. .. ..$ draw: logi FALSE
> .. ..$ x : num 1
> .. ..$ y : num 0.02
> .. ..$ corner: num [1:2] 1 0
> ..$ inside:List of 5
> .. ..$ fun : chr "draw.key"
> .. ..$ x : num 0
> .. ..$ y : num 1
> .. ..$ corner: num [1:2] 0 1
> .. ..$ args :List of 2
> .. .. ..$ key :List of 1
> .. .. .. ..$ text:List of 2
> .. .. .. .. ..$ : chr "a)"
> .. .. .. .. ..$ cex: num 1.5
> .. .. ..$ draw: logi FALSE
>
>>
>> Cheers,
>>
>> --
>> Seb
>>
>> ______________________________________________
>> R-help at 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.
>
> ______________________________________________
> R-help at 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.
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list