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
|
postscript("temp.ps")
library(lattice)
## dotplot labels problem
xx <- 1:10
names(xx) <- rep(letters[1:5], 2)
dotplot(xx)
## missing levels of factors
## drop unused levels
x <- 1:100
y <- rnorm(100)
g <- gl(4, 25, 100)
xyplot(y ~ x | g)
xyplot(y ~ x | g, subset = g != "2")
xyplot(y ~ x | g, subset = g != "2",
panel = function(x, y, subscripts) {
print(subscripts)
ltext(x, y, lab = subscripts)
})
## subset & subscript interaction
x <- rnorm(50)
y <- rnorm(50)
subset <- 20:40
xyplot(y ~ x,
panel = function(x, y, subscripts) {
print(subscripts)
ltext(x, y, lab = subscripts)
})
## gives subscripts = 20:40
xyplot(y ~ x, subset = subset,
panel = function(x, y, subscripts) {
print(subscripts)
ltext(x, y, lab = subscripts)
})
g <- gl(2,1,50)
xyplot(y ~ x, groups = g, panel = panel.superpose)
xyplot(y ~ x, groups = g, panel = panel.superpose, subset = subset)
## reordering tests
data(iris)
iris$foo <- equal.count(iris$Sepal.Length)
foo <- xyplot(Petal.Length ~ Petal.Width | Species + foo, iris)
foo
foo$subset.cond <- list(1:3, 1:6)
foo$perm.cond <- 1:2
foo
foo$perm.cond <- 2:1
foo$subset.cond <- list(c(1,2,3,1), 2:4)
foo
bar <- xyplot(Petal.Length ~ Petal.Width | Species + foo, iris, skip = c(F, T))
bar
bar <- xyplot(Petal.Length ~ Petal.Width | Species + foo, iris, skip = c(F, T), scales = "free")
bar
## other stuff
x <- numeric(0)
y <- numeric(0)
bwplot(y ~ x) # fails? FIXME
x <- c(rnorm(10), rep(NA, 10))
y <- gl(1, 20)
a <- gl(2, 10)
bwplot(x ~ y | a)
## warning: why ?
bwplot(x ~ y | a * a)
## example from Wolfram Fischer
my.barley <- subset( barley, ! ( site == "Grand Rapids" & year == "1932" ) )
dotplot(variety ~ yield | year * site, my.barley,
layout=c(6,2), between=list(x=c(0,6)))
dotplot(variety ~ yield | year * site, data = my.barley,
layout=c(6,2),
scales =
list(rot = 0,
y =
list(relation='sliced',
at = rep( list( FALSE, NULL ), 6 ))),
par.settings =
list(layout.widths = list(axis.panel = rep(c(1, 0), 3))))
dev.off()
|