s-news
[Top] [All Lists]

Re: Invidual scaling when using xyplot - overwriting ylim in a panel

To: <s-news@lists.biostat.wustl.edu>
Subject: Re: Invidual scaling when using xyplot - overwriting ylim in a panel
From: "TKT (Thomas Klitgaard)" <tkt@novonordisk.com>
Date: Mon, 17 Dec 2007 12:17:27 +0100
In-reply-to: <5B833E900330354F9FDA984D06F92428030A72AF@ca-exchange.corp.pharsight.com>
Thread-index: Acg+MwjROx+v3UEtRpmK8Z24SwOMtgCWE0ogAAS8afA=
Thread-topic: [S] Invidual scaling when using xyplot - overwriting ylim in a panel
Very good Andreas! This worked - thank you!
 
BR Thomas
 

From: Andreas Krause [mailto:akrause@Pharsight.com]
Sent: 17. december 2007 10:30
To: TKT (Thomas Klitgaard)
Cc: s-news@lists.biostat.wustl.edu
Subject: RE: [S] Invidual scaling when using xyplot - overwriting ylim in a panel

An easy way out is to let S-Plus determine the axis ranges, and that means having the desired range in the data.
Remember that a point (x, y) does not get plotted if x or y is NA, but the data is still used to determine axis ranges.
The solution is then to append your y data and make the corresponding x missing.
 
If I understand your description correctly, the code should be similar to this:
 
alldata.new <- alldata
alldata.new$DV <- c(alldata$DV, alldata$IPRE, alldata$PRED)
alldata.new$TIME <- c(alldata$TIME, rep(NA, 2*nrow(alldata)))
xyplot(..., data="">
 
  Andreas Krause


From: s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of TKT (Thomas Klitgaard)
Sent: Friday, December 14, 2007 10:24 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] Invidual scaling when using xyplot - overwriting ylim in a panel


Dear all,

As part a modelling problem that I'm currently working on, I need to make plots of
responses DV (observed data value), fittet curve IPRE and fitted curve #2 PRED,
for two groups PK and PD of analysis (indexed by CMT, see below), all in the samme plot, and with
one plot per individual (ID). That the easy bit, however.

Group PK and PD generally in the same range, but the between-ID varation in Ymax is
considerable. Using xyplot (see below), I chose scales=list(y=list="free") to
accommodate this. However, even if individually scaled, still it is max(DV) that
determines the ylim on the individual panels and in those cases where the
max(IPRE) or max(PRED) are > max(DV) within in a panel, lines for IPRE and/or PRED are
cut-off.

I would like overwrite/set, for each panel, ylim to the max(DVgroupPK,IPREgroupPK,PREDgroupPK,
DVgroupPD,IPREgroupPD,PREDgroupPD) in that panel (ie. for that ID). How do I do this?

Thanks in advance!

Thomas Klitgaard
Principal Scientist
Biomodelling, Novo Nordisk A/S, Denmark

----

xyplot(DV~TIME|ID,data="">
                {
                        panel.superpose(x,y,type="p",subscripts,...);
                        panel.superpose(AllResults[subscripts,]$TIME,log10(AllResults[subscripts,]$PRED),type="l",subscripts,...);

                        panel.superpose(AllResults[subscripts,]$TIME,log10(AllResults[subscripts,]$IPRE),type="l",lty=4,subscripts,...);

                        mtext(side=3,line=-1,cex=.8,adj=.95,paste("Dose (ug/kg)=",AllResults[subscripts,]$DOSE))
                },
       
                strip=function(...) strip.default(...,style=1, strip.names=c(T,F),strip.var.names=c("Subject ID")),
                scales=list(y=list(relation="free"),x=list(at=c(0,xGrid),
                labels=c("0","","","","","","","","","","24","","","","","","48","","","","72","","","","96","","","120","","","144","","","168","192","216","240"))),

                main="PK (blue) and PD (red) vs. time (full line: population mean, dashed line: individual mean)",
                xlab="Time after dose (h)",     ylab="Concentration (ng/mL)",xlim=c(0,x.lim), ylim=c(0,y.lim),
                layout=c(2,2),as.table=T)


<Prev in Thread] Current Thread [Next in Thread>