Code where I am explicitly ordering by factor(...)
into levels but its effect is not observed in Rplots.pdf
# data
# http://stackoverflow.com/a/40694900/54964
summary(datm)
datm$male.Nij <- factor(datm$male.Nij, c("Sinus", "Arr/AHB", "Digoxin arr", "Furosemide arr"))
summary(datm)
# http://stackoverflow.com/a/6359164/54964
library(lattice)
lvs = unique(dat$male.Nij) # TODO maybe here something?
barchart(variable ~ value|group + factor(male.Nij, levels=lvs),
groups=gender,
data=datm,
auto.key=list(space='right')
)
Output is correct after datm$male.Nij <- factor(...)
but print into Rplots.pdf shows still the original order
male.Nij gender group variable
Arr/AHB :32 Length:128 Length:128 N11 :16
Digoxin arr :32 Class :character Class :character N22 :16
Furosemide arr:32 Mode :character Mode :character N33 :16
Sinus :32 N44 :16
N21 :16
N31 :16
(Other):32
male.Nij
Sinus :32
Arr/AHB :32
Digoxin arr :32
Furosemide arr:32
Testing user20650's proposal
Code
summary(datm)
barchart(variable ~ value|group + male.Nij,
groups=gender,
data=datm,
auto.key=list(space='right')
)
Output: no change, still wrong output
R: 3.3.2
OS: Debian 8.5