/
xpose.plot.default.R
executable file
·684 lines (619 loc) · 26.2 KB
/
xpose.plot.default.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
#' The Xpose 4 generic functions for continuous y-variables.
#'
#' This function is a wrapper for the lattice xyplot function.
#'
#' \code{y} must be numeric (continuous) while \code{x} can be either numeric
#' of factor. If \code{x} is numeric then a regular xy-plot is drawn. If x is a
#' factor, on the other hand, a box and whiskers plot is constructed.
#'
#' \code{x} and \code{y} can be either single valued strings or vector of
#' strings. \code{x} and \code{y} can not both be vectors in the same call to
#' the function.
#'
#' If \code{ids} is \code{TRUE}, text labels are added to the plotting symbols.
#' The labels are taken from the \code{idlab} xpose data variable. The way the
#' text labels are plotted is governed by the \code{idsmode} argument (passed
#' down to the panel function). \code{idsmode=NULL} (the default) means that
#' only extreme data points are labelled while a non-\code{NULL} value adds
#' labels to all data points (the default in Xpose 3).
#' \code{xpose.panel.default} identifies extreme data points by fitting a loess
#' smooth (\code{y~x}) and looking at the residuals from that fit. Points that
#' are associated with the highest/lowest residuals are labelled. "High" and
#' "low" are judged by the panel function parameter \code{idsext}, which gives
#' the fraction of the total number of data points that are to be judged
#' extreme in the "up" and "down" direction. The default value for
#' \code{idsext} is 0.05 (see \code{\link{xpose.prefs-class}}). There is also a
#' possibility to label only the high or low extreme points. This is done
#' through the \code{idsdir} argument to \code{xpose.panel.default}. A value of
#' "both" (the default) means that both high and low extreme points are
#' labelled while "up" and "down" labels the high and low extreme points
#' respectively.
#'
#' Data dilution is useful is situations when there is an excessive amount of
#' data. \code{xpose.plot.default} can dilute data in two different ways. The
#' first is a completely random dilution in which all individuals are eligible
#' for exclusion from the plot. In this case the argument \code{dilfrac}
#' determines the fraction of individuals that are excluded from the plot. The
#' second type of dilution uses stratification to make sure that none of the
#' extreme individuals are omitted from the plot. Extreme individuals are
#' identified in a similar manner as extreme data points are identified for
#' text labelling. A smooth is fitted to the data and the extreme residuals
#' from that fit is used to inform about extremeness. What is judged as extreme
#' is determined by the argument \code{dilci}, which defaults to 0.95 (Note
#' that the meaning of this is the opposite to \code{idsext}). \code{dilci}
#' give the confidence level of the interval around the fitted curve outside of
#' which points are deemed to be extreme. Extreme individuals are those that
#' have at least one point in the "extremeness" interval. Individuals that do
#' not have any extreme points are eligible for dilution and \code{dilfrac}
#' give the number of these that should be omitted from the graph. This means
#' that \code{dilfrac} should usually be grater for stratified dilution than in
#' completely random dilution. Any smooths added to a diluted plot is based on
#' undiluted data.
#'
#' More graphical parameters may be passed to
#' \code{\link{xpose.panel.default}}.
#'
#' @param x A string or a vector of strings with the name(s) of the
#' x-variable(s).
#' @param y A string or a vector of strings with the name(s) of the
#' y-variable(s).
#' @param object An "xpose.data" object.
#' @param inclZeroWRES A logical value indicating whether rows with WRES=0
#' should be plotted.
#' @param onlyfirst A logical value indicating whether only the first row per
#' individual should be included in the plot.
#' @param samp An integer between 1 and object@Nsim
#' (see\code{\link{xpose.data-class}}) specifying which of the simulated data
#' sets to extract from SData.
#' @param panel The name of the panel function to use.
#' @param groups A string with the name of any grouping variable (used as the
#' groups argument to \code{panel.xyplot}.
#' @param ids A logical value indicating whether text labels should be used as
#' plotting symbols (the variable used for these symbols indicated by the
#' \code{idlab} xpose data variable).
#' @param logy Logical value indicating whether the y-axis should be
#' logarithmic.
#' @param logx Logical value indicating whether the x-axis should be
#' logarithmic.
#' @param yscale.components Used to change the way the axis look if \code{logy}
#' is used. Can be a user defined function or
#' \code{link{xpose.yscale.components.log10}}. If the axes are not log
#' transformed then
#' \code{\link[lattice:axis.default]{yscale.components.default}} is used.
#' @param xscale.components Used to change the way the axis look if \code{logx}
#' is used. Can be a user defined function or
#' \code{link{xpose.xscale.components.log10}}. If the axes are not log
#' transformed then
#' \code{\link[lattice:axis.default]{xscale.components.default}} is used.
#' @param aspect The aspect ratio of the display (see
#' \code{\link[lattice]{xyplot}}).
#' @param funx String with the name of a function to apply to the x-variable
#' before plotting, e.g. "abs".
#' @param funy String with the name of a function to apply to the y-variable
#' before plotting, e.g. "abs".
#' @param iplot Is this an individual plots matrix? Internal use only.
#' @param PI Either "lines", "area" or "both" specifying whether prediction
#' intervals (as lines, as a shaded area or both) should be computed from the
#' data in \code{SData} and added to the display. \code{NULL} means no
#' prediction interval.
#' @param by A string or a vector of strings with the name(s) of the
#' conditioning variables.
#' @param force.by.factor Logical value. If TRUE, and \code{by} is not
#' \code{NULL}, the variable specified by \code{by} is taken as categorical.
#' @param ordby A string with the name of a variable to be used to reorder any
#' factor conditioning variables (\code{by}). The variable is used in a call to
#' the \code{reorder.factor} function.
#' @param byordfun The name of the function to be used when reordering a factor
#' conditioning variable (see argument \code{ordby})
#' @param shingnum The number of shingles ("parts") a continuous conditioning
#' variable should be divided into.
#' @param shingol The amount of overlap between adjacent shingles (see argument
#' \code{shingnum})
#' @param by.interval The intervals to use for conditioning on a continuous
#' variable with \code{by}.
#' @param strip The name of the function to be used as the strip argument to
#' the \code{\link[lattice]{xyplot}}. An easy way to change the strip
#' appearance is to use \code{\link[lattice]{strip.custom}}. For example, if
#' you want to change the text in the strips you can use
#' \code{strip=strip.custom(factor.levels=c("Hi","There"))} if the \code{by}
#' variable is a factor and \code{strip=strip.custom(var.name=c("New Name"))}
#' if the \code{by} variable is continuous.
#' @param use.xpose.factor.strip.names Use factor names in strips of
#' conditioning plots..
#' @param main A string giving the plot title or \code{NULL} if none.
#' @param xlb A string giving the label for the x-axis. \code{NULL} if none.
#' @param ylb A string giving the label for the y-axis. \code{NULL} if none.
#' @param subset A string giving the subset expression to be applied to the
#' data before plotting. See \code{\link{xsubset}}.
#' @param autocorr Is this an autocorrelation plot? Values can be
#' \code{TRUE/FALSE}.
#' @param scales A list to be used for the \code{scales} argument in
#' \code{\link[lattice]{xyplot}}.
#' @param suline A string giving the variable to be used to construct a smooth
#' to superpose on the display. \code{NULL} if none. This argument is used if
#' you want to add a superpose line of a variable not present in the \code{y}
#' list of variables.
#' @param bwhoriz A logical value indicating if box and whiskers bars should be
#' plotted horizontally or not. Used when the x-variable(s) is categorical.
#' @param dilution Logical value indicating whether data dilution should be
#' used.
#' @param diltype Indicating what type of dilution to apply. \code{NULL} means
#' random dilution without stratification. A non\code{NULL} value means
#' stratified dilution.
#' @param dilfrac Dilution fraction indicating the expected fraction of
#' individuals to display in the plots. The exact meaning depends on the type
#' of dilution (see below).
#' @param dilci A number between 0 and 1 giving the range eligible for dilution
#' in a stratified dilution (see below).
#' @param seed Seed number used for random dilution. \code{NULL} means no seed.
#' @param mirror Should we create mirror plots from simulation data? Value can
#' be \code{FALSE}, \code{TRUE} or \code{1} for one mirror plot, or \code{3}
#' for three mirror plots.
#' @param max.plots.per.page The maximum number of plots per page that can be
#' created with the mirror plots.
#' @param mirror.aspect The aspect ratio of the plots used for mirror
#' functionality.
#' @param pass.plot.list Should we pass the list of plots created with mirror
#' or should we print them directly. Values can be \code{TRUE/FALSE}.
#' @param x.cex The size of the x-axis label.
#' @param y.cex The size of the y-axis label.
#' @param main.cex The size of the title.
#' @param mirror.internal an internal mirror argument used in
#' \code{\link{create.mirror}}. Checks if the \code{strip} argument from
#' \code{\link[lattice]{xyplot}} has been used.
#' @param \dots Other arguments passed to \code{\link{xpose.panel.default}}.
#' @return Returns a xyplot graph object.
#' @author E. Niclas Jonsson, Mats Karlsson, Andrew Hooker & Justin Wilkins
#' @seealso \code{\link{xpose.panel.default}}, \code{\link[lattice]{xyplot}},
#' \code{\link[lattice]{panel.xyplot}}, \code{\link{xpose.prefs-class}},
#' \code{\link{xpose.data-class}}
#' @keywords methods
#' @examples
#'
#' \dontrun{
#' ## xpdb5 is an Xpose data object
#' ## We expect to find the required NONMEM run and table files for run
#' ## 5 in the current working directory
#' xpdb5 <- xpose.data(5)
#'
#' ## A spaghetti plot of DV vs TIME
#' xpose.plot.default("TIME", "DV", xpdb5)
#'
#' ## A conditioning plot
#' xpose.plot.default("TIME", "DV", xpdb5, by = "SEX")
#'
#' ## Multiple x-variables
#' xpose.plot.default(c("WT", "SEX"), "CL", xpdb5)
#'
#' ## Multiple y-variables
#' xpose.plot.default("WT", c("CL", "V"), xpdb5)
#' xpose.plot.default("WT", c("CL", "V"), xpdb5, by=c("SEX", "HCTZ"))
#'
#' ## determining the interval for the conditioning variable
#' wt.ints <- matrix(c(50,60,60,70,70,80,80,90,90,100,100,150),nrow=6,ncol=2,byrow=T)
#' xpose.plot.default("TIME","DV",xpdb5,by="WT", by.interval=wt.ints)
#' }
#'
#'
#' @export xpose.plot.default
xpose.plot.default <-
function(x,y,object,
inclZeroWRES = FALSE,
onlyfirst = FALSE,
samp = NULL,
panel = xpose.panel.default,
groups = object@Prefs@Xvardef$id,
ids = object@Prefs@Graph.prefs$ids,
logy = FALSE,
logx = FALSE,
yscale.components= "default",#function(...) yscale.components.default(...),
xscale.components= "default",#function(...) xscale.components.default(...),
aspect = object@Prefs@Graph.prefs$aspect,
funx = NULL,
funy = NULL,
iplot = NULL,
## Prediction interval settings
PI = NULL,
## Conditioning settings
by = object@Prefs@Graph.prefs$condvar,
force.by.factor = FALSE,
ordby = object@Prefs@Graph.prefs$ordby,
byordfun = object@Prefs@Graph.prefs$byordfun,
shingnum = object@Prefs@Graph.prefs$shingnum,
shingol = object@Prefs@Graph.prefs$shingol,
by.interval = NULL,
##par.strip.text=trellis.par.get("add.text"),
##mirror.par.strip.text=trellis.par.get("add.text"),
strip = function(...){
strip.default(...,strip.names=c(TRUE,TRUE))
},
use.xpose.factor.strip.names=TRUE,
##strip.nams=T,
##strip=strip.custom(strip.names=c(T,T)),
##par.strip.text = mirror.par.strip.text),
##par.strip.text = trellis.par.get("add.text"),
##par.strip.text=NULL,
## Subset stuff
subset = xsubset(object),
autocorr=FALSE,
## Axes and titles
main = xpose.create.title(x,y,object,subset,funx,funy,...),
#main = NULL,
xlb = xpose.create.label(x,object,funx,logx,autocorr.x=autocorr,...),
ylb = xpose.create.label(y,object,funy,logy,autocorr.y=autocorr,...),
##xlb = ifelse((length(x)>1),"Value",xlabel(x,object)),
##ylb = ifelse((length(y)>1),"Value",xlabel(y,object)),
scales = list(),
## Superpose smooth
suline = object@Prefs@Graph.prefs$suline,
## Categorical stuff
bwhoriz = object@Prefs@Graph.prefs$bwhoriz,
## Dilution stuff
dilution = FALSE,
dilfrac = object@Prefs@Graph.prefs$dilfrac,
diltype = object@Prefs@Graph.prefs$diltype,
dilci = object@Prefs@Graph.prefs$dilci,
seed = NULL,
mirror = FALSE,
max.plots.per.page=4,
mirror.aspect="fill",
pass.plot.list=FALSE,
x.cex = NULL,
y.cex = NULL,
main.cex = NULL,
mirror.internal=list(strip.missing=missing(strip)),
...
) {
## CHecks if use.xpose.factor.strip.names is a logical of length 1
if (!(is.logical(use.xpose.factor.strip.names) &
length(use.xpose.factor.strip.names)==1)){
stop("The provided use.xpose.factor.strip.names argument is not a logical of length 1")
}
plotTitle <- main
## for MIRROR functionality
arg.list <- formals(xpose.plot.default)
arg.names <- names(arg.list)
new.arg.list <- vector("list",length(arg.names))
names(new.arg.list) <- arg.names
for (argnam in arg.names){
if (argnam=="..."){
next
}
tmp <- get(argnam)
if (is.null(tmp)){
} else {
new.arg.list[[argnam]]=tmp
}
}
if (mirror){
if(is.null(object@Nsim)) {
cat(paste("The current Xpose database does not have any simulation data.\n"))
cat(paste("The mirror option cannot be used.\n"))
return(NULL)
}
create.mirror(xpose.plot.default,
new.arg.list,mirror,plotTitle,...)
} else { # end if mirror
##Get data
if(any(is.null(iplot))) {
if(!is.null(samp)) {
#cat(samp)
data <- SData(object,inclZeroWRES,onlyfirst=onlyfirst,
subset=subset,samp=samp)
} else {
data <- Data(object,inclZeroWRES,onlyfirst=onlyfirst,subset=subset)
}
} else {
data <- Data(object,inclZeroWRES,onlyfirst=onlyfirst,subset=NULL)
}
## Strip "missing" data
all_variables <- c(x,y)
for(i_var in all_variables){
data <- subset(data, get(i_var) != object@Prefs@Miss)
}
if(any(is.null(data))) return("The subset expression is invalid.")
## Make sure by is a factor if requested
if(!is.null(by) && force.by.factor) {
for(b in by) {
data[,b] <- as.factor(data[,b])
}
}
## Sort out dilution
dilsubset <- TRUE
dilname <- NULL
if(dilution) {
if(is.null(diltype)) { # Standard random dilution
data <- create.rand(data,object,dilfrac,seed=seed)
if(is.null(seed)) {
dilsubset <- parse(text="Rnoseed==0")
dilname <- "Rnoseed"
} else {
dilsubset <- parse(text=paste("R",seed,"==0",sep=""))
dilname <- paste("R",seed,"==0",sep="")
}
} else { # Stratified random dilution
data <-create.strat.rand(data,object,x,y,dilfrac,dilci,seed=seed)
if(is.null(seed)) {
dilsubset <- parse(text="RSnoseed==0")
dilname <- "RSnoseed"
} else {
dilsubset <- parse(text=paste("RS",seed,,"==0",sep=""))
dilname <- paste("RS",seed,,"==0",sep="")
}
}
}
## Check to see if x and y are both longer than 1
if(length(x)>1 && length(y)>1) {
cat("x and y can not both be longer than 1\n")
return()
}
## Check to see if more than one x-variable
if(length(x) > 1) {
reps <-c(xvardef("id",object),xvardef("idlab",object),
xvardef("wres",object),y,groups)
if(!is.null(dilname)) reps <- c(reps,dilname)
if(!is.null(by)) reps <- c(reps,by)
#data <- stack.xpose(data,object,x,reps)
data <- xpose.stack(data,object,x,reps)
object <- new("xpose.data",
Runno=object@Runno,
Data = NULL,
Prefs = object@Prefs)
Data(object) <- data
#cat(object@Prefs@Graph.prefs$type)
if(is.null(main.cex)) main.cex <- 0.9
onlyfirst = FALSE
if(is.null(by)) {
by <- "ind"
} else {
by <- c("ind",by)
}
x <- "values"
## If scales is longer than one then the users has supplied it
##as an argument.
if(length(scales)==0) {
scales=list(x=list(relation="free"))
}
}
## Check to see if more than one y-variable
if(length(y) > 1) {
reps <- c(object@Prefs@Xvardef["id"],
object@Prefs@Xvardef["idlab"],
xvardef("wres",object),x,groups)
if(!is.null(dilname)) reps <- c(reps,dilname)
if(!is.null(by)) reps <- c(reps,by)
#data <- stack.xpose(data,object,y,reps)
data <- xpose.stack(data,object,y,reps)
object <- new("xpose.data",
Runno=object@Runno,
Data = NULL,
Prefs = object@Prefs)
Data(object) <- data
if(is.null(main.cex)) main.cex <- 0.9
onlyfirst = FALSE
if(is.null(by)) {
by <- "ind"
} else {
by <- c("ind",by)
}
y <- "values"
## If scales is longer than one then the users has supplied it
##as an argument.
if(length(scales)==0) {
scales=list(y=list(relation="free"))
}
}
## Collect the basic plot formula
bb <- NULL
groups <- groups
if(any(is.null(by))) {
if(bwhoriz) {
formel <- paste(x,"~",y,sep="")
} else {
formel <- paste(y,"~",x,sep="")
}
} else {
for(b in by) {
##b <- by[bs]
bb <- c(bb,xlabel(b,object))
if(!is.factor(data[,b])) {
if(is.null(by.interval)){
data[,b] <- equal.count(data[,b],number=shingnum,overl=shingol)
} else {
data[,b] <- shingle(data[,b],intervals=by.interval)
}
} else {
if(any(!is.null(ordby))) {
data[,b] <- reorder(data[,b],data[,ordby],byordfun)
}
if(names(data[,b,drop=F])!="ind") {
if(use.xpose.factor.strip.names){
levels(data[,b]) <-
paste(xlabel(names(data[,b,drop=F]),object),":", ## Needs to be fixed
levels(data[,b]),sep="")
}
}
}
}
bys <- paste(by,collapse="*")
if(bwhoriz) {
formel <- paste(x,"~",y,"|",bys,sep="")
} else {
formel <- paste(y,"~",x,"|",bys,sep="")
}
}
if(missing(strip)) {
strip <- function(var.name,...)
strip.default(var.name=bb,strip.names=c(F,T),...)
}
## Check to see if panel.superpose should be used
if(any(!is.null(groups))) groups <- data[,groups]
## CHeck to see if a superpose smooth is to be used.
if(!is.null(suline)) {
suline <- data[,suline]
}
## Check for id-numbers as plotting symbols
##if(!is.null(ids)) ids <- data[,xvardef("idlab",object)]
if(ids){
ids <- data[,xvardef("idlab",object)]
} else {
ids <- NULL
}
## Apply function to x-variable
if(!is.null(funx)) {
data[,x] <- do.call(funx,list(data[,x]))
}
## Apply function to y-variable
if(!is.null(funy)) {
data[,y] <- do.call(funy,list(data[,y]))
## if(!is.null(ylb[1])){
## ##if(ylb[1]==xlabel(y,object)) {
## if(missing(ylb)) {
## if (fun=="abs"){
## ylb <- paste("|",ylb,"|",sep="")
## } else {
## ylb <- paste(fun,"(",ylb,")",sep="")
## }
## }
## }
}
## Sort out the scales
yscale.components.defined <- T
xscale.components.defined <- T
if(!is.function(yscale.components)){
if(!is.na(match(yscale.components,"default"))) {
yscale.components= function(...) yscale.components.default(...)
yscale.components.defined <- F
}
}
if(!is.function(xscale.components)){
if(!is.na(match(xscale.components,"default"))) {
xscale.components= function(...) xscale.components.default(...)
xscale.components.defined <- F
}
}
if(logy) {
scales$y$log <- TRUE
if(!yscale.components.defined){
yscale.components=xpose.yscale.components.log10
}
}
if(logx) {
scales$x$log <- TRUE
if(!xscale.components.defined){
xscale.components=xpose.xscale.components.log10
}
}
xvarnam <- x
yvarnam <- y
if(!is.null(x.cex)) {
if (is.list(xlb)){
xlb$cex=x.cex
} else {
xlb <- list(xlb,cex=x.cex)
}
}
if(!is.null(y.cex)) {
if (is.list(ylb)){
ylb$cex=y.cex
} else {
ylb <- list(ylb,cex=y.cex)
}
}
if(is.null(main)) {
} else {
if(!is.null(main.cex)) {
if (is.list(main)){
main$cex=main.cex
} else {
main <- list(main,cex=main.cex)
}
}
}
## for autocorrelation (not working completely yet)
if(autocorr){
auto.ids <- unique(data[[xvardef("id",object)]])
auto.n <- 0
xplt1 <- 0
xplt2 <- 0
xgrps <- 0
for(i in 1:length(auto.ids)) {
i <- 1
seli <- data[[xvardef("id",object)]] == ids[i]
nobs <- length(data[[x]][seli])
xplt <- matrix(data[[x]][seli], 1, nobs)
if(nobs > 1) {
for(j in 1:(nobs - 1)) {
auto.n <- auto.n + 1
xplt1[auto.n] <- xplt[1, j]
xplt2[auto.n] <- xplt[1, j + 1]
xgrps[auto.n] <- auto.ids[i]
}
}
}
#xlb <- paste(xlb,"(i)",sep="")
#ylb <- paste(ylb,"(i+1)",sep="")
#x <- xplt1
#y <- xplt2
#groups <- xgrps
}
xplot <- xyplot(formula(formel),data,obj=object,
prepanel = function(x,y) {
xlim <- NULL
ylim <- NULL
ret <- list()
if(is.factor(x)){#length(levs <- unique(x)) < object@Prefs@Cat.levels) {
if(length(grep("[A-Z,a-z]",levels(x)))==0) {
xlim <- as.character(sort(as.numeric(levels(x))))
} else {
xlim <- sort(levels(x))
}
} else {
#xlim <- range(x)
}
ret[["xlim"]] <- xlim
if(is.factor(y)){#length(levs <- unique(x)) < object@Prefs@Cat.levels) {
if(length(grep("[A-Z,a-z]",levels(y)))==0) {
ylim <- as.character(sort(as.numeric(levels(y))))
} else {
ylim <- sort(levels(y))
}
} else {
#ylim <- range(y)
}
ret[["ylim"]] <- ylim
#list(xlim=xlim,ylim=ylim)
return(ret)
},
onlyfirst = onlyfirst,
samp = samp,
panel = panel,
strip = strip,
##par.strip.text = par.strip.text,
groups=groups,
inclZeroWRES=inclZeroWRES,
PI = PI,
logy=logy,
logx=logx,
xscale.components=xscale.components,
yscale.components=yscale.components,
xvarnam = xvarnam,
yvarnam = yvarnam,
ids = ids,
main=main,
xlab=xlb,
ylab=ylb,
aspect=aspect,
suline=suline,
bwhoriz = bwhoriz,
subset=eval(dilsubset),
scales=scales,
iplot=iplot,
autocorr=autocorr,
#autocorr=FALSE,
PI.subset=subset,
#drop.unused.levels=FALSE,
...)
return(xplot)
}
}