Extend matrix reshaping functions to trellis objects.

Share:

Description

Extend matrix reshaping functions to trellis objects. See the details section for comparisons with similar functions in the lattice package.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
transpose(x)
## S3 method for class 'trellis'
transpose(x)
## Default S3 method:
transpose(x)
## S3 method for class 'trellis'
aperm(a, perm, ...)
## S3 method for class 'trellis'
rbind(..., deparse.level=1,
      combineLimits=TRUE, useOuterStrips=TRUE)
## S3 method for class 'trellis'
cbind(..., deparse.level=1,
      combineLimits=TRUE, useOuterStrips=TRUE)

Arguments

..., x, a

A set of trellis objects.

perm

Permutation vector, see aperm for details.

combineLimits, useOuterStrips

logical. If TRUE (the default), use the similarly named latticeExtra functions before returning the result.

deparse.level

See cbind for details. These functions ignore this argument and always use the names(list(...)), if non-NULL, for the labels. If NULL, then the first length(list(...)) uppercase letters are used.

Details

transpose.trellis tries to capture and modify all potentially relevant trellis components. transpose.trellis is more comprehensive than the similar t.trellis which adjusts only the perm.cond component.

aperm.trellis does not attempt to check all potentially relevant trellis components. It does not adjust layout.heights, layout.widths, or between It may show strange axis positions or strip positions for any non-standard arrangement, for example, for any trellis object that has already been through latticeExtra::combineLimits.

Value

trellis object constructed from arguments with new dim and layout.

Author(s)

Richard M. Heiberger <rmh@temple.edu>

Examples

 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
F <- xyplot((1:15) ~ (1:15) | rep(factor(letters[3:5]), each=5))
G <- xyplot((1:18) ~ (1:18) | rep(factor(letters[3:5]), each=6))
rbind(AAA=F, BBB=G)
cbind(AAA=F, BBB=G)

tmp <- data.frame(y=1:24,
                  x=1:24,
                  a=rep(letters[1:2], each=12),
                  b=rep(letters[3:5], each=4, times=2),
                  c=rep(letters[6:9], times=6))

t3 <- xyplot(y ~ x | c*b*a, data=tmp,
             panel=function(x, y, ...) panel.text(x, y, y),
             scales=list(alternating=FALSE))
## t3
t3u <- update(t3, layout=c(4*3, 2), between=list(x=c(0,0,0,1)), main="t3")
useOuterStripsT2L1(t3u)

## Not run: 
## update(t3, layout=c(24, 1))

t3.321 <- aperm(t3, c(3,2,1))
update(t3.321, main="t3.321", layout=c(6,4), between=list(x=c(0,1))) ## 2*3,4

try(transpose(t3))   ## requires a one- or two-dimensional trellis object.

t3.123 <- aperm(t3, c(1,2,3)) ## identity operation
t3.132 <- aperm(t3, c(1,3,2))
t3.213 <- aperm(t3, c(2,1,3))
t3.231 <- aperm(t3, c(2,3,1))
t3.312 <- aperm(t3, c(3,1,2))
t3.321 <- aperm(t3, c(3,2,1))

u3.123 <- update(t3.123, main="t3.123", layout=c(12,2),
                 between=list(x=c(0,0,0,1))) ## 4*3,2
u3.132 <- update(t3.132, main="t3.132", layout=c(8,3),
                 between=list(x=c(0,0,0,1))) ## 4*2,3
u3.213 <- update(t3.213, main="t3.213", layout=c(3,8),
                 between=list(y=c(0,0,0,1)), par.strip.text=list(cex=.8)) ## 3,4*2
u3.231 <- update(t3.231, main="t3.231", layout=c(6,4),
                 between=list(x=c(0,0,1))) ## 2*3,4
u3.312 <- update(t3.312, main="t3.312", layout=c(2,12),
                 between=list(y=c(0,0,0,1)), par.strip.text=list(cex=.6)) ## 2,3*4
u3.321 <- update(t3.321, main="t3.321", layout=c(6,4),
                 between=list(x=c(0,1))) ## 2*3,4

pdf("u5.pdf", width=17, height=22)
print(u3.123, split=c(1,1,2,3), more=TRUE)
print(u3.132, split=c(2,1,2,3), more=TRUE)
print(u3.213, split=c(1,2,2,3), more=TRUE)
print(u3.231, split=c(2,2,2,3), more=TRUE)
print(u3.312, split=c(1,3,2,3), more=TRUE)
print(u3.321, split=c(2,3,2,3), more=FALSE)
dev.off()

try(transpose(t3.123)) ## layout is a matrix, but dim is not.

## End(Not run)

## Not run: 
t2 <- xyplot(y ~ x | b*c, data=tmp,
             panel=function(x, y, ...) panel.text(x, y, y),
             scales=list(alternating=FALSE))
t2

## aperm(t2, 1:2) ## identity

transpose(t2)
aperm(t2, 2:1)

t1a <- xyplot(y ~ x | b, data=tmp[tmp$a=="a",])
t1b <- xyplot(y ~ x | b, data=tmp[tmp$a=="b",])
t1a
t1b

rbind(t1a, t1b)
rbind(AAA=t1a, BBB=t1b)

cbind(t1a, t1b)
cbind(AAA=t1a, BBB=t1b)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.