Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

2018-04-27 Thread Duncan Mackay
Hi Paul, Rolf

I do not know how legal this is but this works if you have spaces around the 
ultimate plot due to changes in layout
Changing the layout parameters removes the unwanted space.

ap = dotplot(variety ~ yield | year * site, data=barley,layout = c(2,6))
apm = ap[1:2,3:4]
apm$layout <- c(2,2)
apm

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2350


-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Paul Murrell
Sent: Friday, 27 April 2018 11:28
To: Rolf Turner
Cc: r-help@r-project.org; deepayan.sar...@r-project.org
Subject: Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") 
object.

Hi

Does this not do what you want ... ?

allpages <- dotplot(variety ~ yield | year * site, data=barley,
 layout=c(2,2))
page2 <- allpages[1:2, 3:4]
print(page2)

Paul

On 24/04/18 17:51, Rolf Turner wrote:
> 
> On 24/04/18 15:17, Paul Murrell wrote:
> 
>> Hi
>>
>> I think the subsetting works by giving you the panels for the 
>> corresponding levels of the conditioning variable(s).  Note that, if 
>> there is more than one conditioning variable, you will need more than 
>> one subsetting index.
>>
>> For example, taking this plot with two conditioning variables and 12 
>> panels in total ...
>>
>> dotplot(variety ~ yield | year * site, data=barley)
>>
>> ... this produces three pages ...
>>
>> dotplot(variety ~ yield | year * site, data=barley,
>>  layout=c(2,2))
>>
>> ... and this produces the second page (both panels for the first 
>> conditioning variable and the third and fourth panels for the second 
>> conditioning variable) ...
>>
>> dotplot(variety ~ yield | year * site, data=barley,
>>  layout=c(2,2))[1:2, 3:4]
>>
>> Hope that helps.
> 
> Hmm.  Thanks Paul.  I may be able to work with that.  But what I really 
> wanted was to take
> 
>  bar <- dotplot(variety ~ yield | year * site, data=barley)
> 
> and then do (something like)
> 
>  foo <- bar[]
> 
> so that foo contains only the second page of bar, and then do print(foo)
> to get a plot of (just) the second page.  Without re-issuing a 
> (modified) plot command.
> 
> Is that not at all possible?
> 
> cheers,
> 
> Rolf.
> 

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.

__
R-help@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.


Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

2018-04-26 Thread Paul Murrell

Hi

Does this not do what you want ... ?

allpages <- dotplot(variety ~ yield | year * site, data=barley,
layout=c(2,2))
page2 <- allpages[1:2, 3:4]
print(page2)

Paul

On 24/04/18 17:51, Rolf Turner wrote:


On 24/04/18 15:17, Paul Murrell wrote:


Hi

I think the subsetting works by giving you the panels for the 
corresponding levels of the conditioning variable(s).  Note that, if 
there is more than one conditioning variable, you will need more than 
one subsetting index.


For example, taking this plot with two conditioning variables and 12 
panels in total ...


dotplot(variety ~ yield | year * site, data=barley)

... this produces three pages ...

dotplot(variety ~ yield | year * site, data=barley,
 layout=c(2,2))

... and this produces the second page (both panels for the first 
conditioning variable and the third and fourth panels for the second 
conditioning variable) ...


dotplot(variety ~ yield | year * site, data=barley,
 layout=c(2,2))[1:2, 3:4]

Hope that helps.


Hmm.  Thanks Paul.  I may be able to work with that.  But what I really 
wanted was to take


     bar <- dotplot(variety ~ yield | year * site, data=barley)

and then do (something like)

     foo <- bar[]

so that foo contains only the second page of bar, and then do print(foo)
to get a plot of (just) the second page.  Without re-issuing a 
(modified) plot command.


Is that not at all possible?

cheers,

Rolf.



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.


Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

2018-04-24 Thread Duncan Mackay
Hi Rolf

do you need to use the  layout argument?

The layout is conditioned by the levels of a or unique values if not a factor. 
easier with factor

unique(dta$a)
 [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l"
data.frame( a= unique(dta$a), page = rep(1:3, ea = 4), col = 1:2,row  = 
rep(1:2, ea = 2))
   a page col row
1  a1   1   1
2  b1   2   1
3  c1   1   2
4  d1   2   2
5  e2   1   1
6  f2   2   1
7  g2   1   2
8  h2   2   2
9  i3   1   1
10 j3   2   1
11 k3   1   2
12 l3   2   2

I hope I have got the order right

full dataset
xyplot(y~x|a,data=dta)


 bar  = xyplot(y~x|a,data = subset(dta, a %in% c("e","f","g","h")) ))

print(bar)
(missed the dotplot requirement) but principle is the same.

you can use packet.number or which.packet if needed to make it simpler

use par.settings to do colours lines etc as well as spacing.

Regards

Duncan

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2350

-Original Message-
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Rolf Turner
Sent: Tuesday, 24 April 2018 15:52
To: Paul Murrell
Cc: r-help@r-project.org; deepayan.sar...@r-project.org
Subject: Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") 
object.


On 24/04/18 15:17, Paul Murrell wrote:

> Hi
> 
> I think the subsetting works by giving you the panels for the 
> corresponding levels of the conditioning variable(s).  Note that, if 
> there is more than one conditioning variable, you will need more than 
> one subsetting index.
> 
> For example, taking this plot with two conditioning variables and 12 
> panels in total ...
> 
> dotplot(variety ~ yield | year * site, data=barley)
> 
> ... this produces three pages ...
> 
> dotplot(variety ~ yield | year * site, data=barley,
>  layout=c(2,2))
> 
> ... and this produces the second page (both panels for the first 
> conditioning variable and the third and fourth panels for the second 
> conditioning variable) ...
> 
> dotplot(variety ~ yield | year * site, data=barley,
>  layout=c(2,2))[1:2, 3:4]
> 
> Hope that helps.

Hmm.  Thanks Paul.  I may be able to work with that.  But what I really 
wanted was to take

 bar <- dotplot(variety ~ yield | year * site, data=barley)

and then do (something like)

 foo <- bar[]

so that foo contains only the second page of bar, and then do print(foo)
to get a plot of (just) the second page.  Without re-issuing a 
(modified) plot command.

Is that not at all possible?

cheers,

Rolf.

-- 
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@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.

__
R-help@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.


Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

2018-04-23 Thread Rolf Turner


On 24/04/18 15:17, Paul Murrell wrote:


Hi

I think the subsetting works by giving you the panels for the 
corresponding levels of the conditioning variable(s).  Note that, if 
there is more than one conditioning variable, you will need more than 
one subsetting index.


For example, taking this plot with two conditioning variables and 12 
panels in total ...


dotplot(variety ~ yield | year * site, data=barley)

... this produces three pages ...

dotplot(variety ~ yield | year * site, data=barley,
     layout=c(2,2))

... and this produces the second page (both panels for the first 
conditioning variable and the third and fourth panels for the second 
conditioning variable) ...


dotplot(variety ~ yield | year * site, data=barley,
     layout=c(2,2))[1:2, 3:4]

Hope that helps.


Hmm.  Thanks Paul.  I may be able to work with that.  But what I really 
wanted was to take


bar <- dotplot(variety ~ yield | year * site, data=barley)

and then do (something like)

foo <- bar[]

so that foo contains only the second page of bar, and then do print(foo)
to get a plot of (just) the second page.  Without re-issuing a 
(modified) plot command.


Is that not at all possible?

cheers,

Rolf.

--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276

__
R-help@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.


Re: [R] [FORGED] Extracting specified pages from a lattice ("trellis") object.

2018-04-23 Thread Paul Murrell

Hi

I think the subsetting works by giving you the panels for the 
corresponding levels of the conditioning variable(s).  Note that, if 
there is more than one conditioning variable, you will need more than 
one subsetting index.


For example, taking this plot with two conditioning variables and 12 
panels in total ...


dotplot(variety ~ yield | year * site, data=barley)

... this produces three pages ...

dotplot(variety ~ yield | year * site, data=barley,
layout=c(2,2))

... and this produces the second page (both panels for the first 
conditioning variable and the third and fourth panels for the second 
conditioning variable) ...


dotplot(variety ~ yield | year * site, data=barley,
layout=c(2,2))[1:2, 3:4]

Hope that helps

Paul

On 14/04/18 12:25, Rolf Turner wrote:


Suppose that (e.g.) xyplot() returns an object "xxx" with (say) 3 pages.
I would like to extract/plot (print) just one of these pages, e.g.
page 2.

Here's a toy example:

x   <- rep(seq(0,1,length=11),12)
set.seed(42)
y   <- rnorm(3*44)
a   <- rep(letters[1:12],each=11)
dta <- data.frame(x=x,y=y,a=a)
xxx <- xyplot(y~x|a,data=dta,layout=c(2,2))

I would to extract from xxx and print page 2 (the page corresponding to
levels e, f, g and h).

Is there any (simple) way that I can do this?

I've mucked around with update.trellis() and [.trellis, but I cannot 
make head nor tail of the documentation.  The [.trellis method seems to 
work in some situations, but not in others, and since I cannot 
understand what it actually does, I cannot figure out why.


E.g. in my toy example "xxx[5:8]" seems to give me what I want, but in 
the context of my real application a similar construction does not work.


Thanks for any insight.

cheers,

Rolf Turner



--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@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.