私はデータフレームを持っています
df <- data.frame(
site=rep(c("s1","s2","s3"),3),
grp=c("a","a","a","b","b","b","c","c","c"),
total=c(0,1,2,0,4,6,8,0,2)
)
df
site grp total
1 s1 a 0
2 s2 a 1
3 s3 a 2
4 s1 b 0
5 s2 b 4
6 s3 b 6
7 s1 c 8
8 s2 c 0
9 s3 c 2
#that I use to create the following lattice plot
library(lattice)
median<-with(df,reorder(grp,total,mean))
df$median<-median
df1<-subset(df,total!=0)
barchart(df$site~total|median,data=df, xlim=c(0,10), col="grey", border="NA",
par.settings=list(axis.text=list(cex=0.85), fontsize=list(text=10)),
par.strip.text=list(cex=0.9), par.strip.col="white", layout = c(3,2),
aspect = (0.3),scales=list(y=list(relation="free"))
)
バーを均等に配置し、df$grp の各レベル (iea、b、c) の df$total を減らして配置したいと考えています。何か案は?ありがとう