# [R] lattice strip.custom in plot for multiple groups

Luigi Marongiu marongiu.luigi at gmail.com
Fri Dec 18 21:22:16 CET 2015

```Dear all,
I am plotting the count of some data subdivided in different groups.
the variables i am using are:
A = tests performed
B = positive/negative results (but in this case the results are all
positive, so all 1)
C = multiple (1) or single (0) test applied
D = count of instances
E = cases (1) or controls (0)

the plot looks the way I need and it is created with lattice's
barchart. However the strip should indicate "cases"/"controls" and
instead only shows "E"/"E" so I think I messed somewhere.
Would you know what did I missed?
Thank you
L

The example:
>>>
A <- c('a',    'b',    'c',    'd',    'a',    'b',    'c',    'd',
'b',    'c',    'd',    'b',    'c',    'd')
B <- c(1,    1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
1,    1,    1)
C <- c(0,    0,    0,    0,    1,    1,    1,    1,    0,    0,    0,
1,    1,    1)
D <- c(4,    120,    7,    23,    4,    24,    3,    12,    7,    1,
1,    5,    0,    0)
E <- c(0,    0,    0,    0,    0,    0,    0,    0,    1,    1,    1,
1,    1,    1)
DF <- data.frame(A, B, C, D, E, stringsAsFactors = FALSE)
library(lattice)
barchart(
A ~ D|E,
DF,
groups = C,
stack = TRUE,
main = "Comparison of test results",
xlab = "Count",
col = c("yellow", "orange"),
par.settings = list(
strip.background = list(col="light grey"),
superpose.polygon=list(col= c("yellow", "orange"))
),
scales = list(
alternating = FALSE
),
key = list(
space="top",
columns=2,
text=list(c("Single infections", "Multiple infections"), col="black"),
rectangles=list(col=c("yellow", "orange"))
),
strip = strip.custom(factor.levels = c("Cases","Controls"),
par.strip.text = list(cex = 1)
)
)

```