0

我是 R 的新用户。 • 我想将这两个组的结果结合起来,并且仍然将它们的标签保持为两个组。当我合并时,它们产生了一个丢失了标签的图形。• 我还想将数字 1 和 2(对于两组)标记为“下降”和“下降-上升”。分别用“黑色”和“灰色”颜色来轻松显示差异。• 我正在处理汇总结果

这是我迄今为止用来创建图形的公式:

d0<-matrix(c(x1,x2), ncol=2)
d1<-matrix(c(y1,y2), ncol=2)
lmts<-range(d0,d1)
par(mfrow = c(1, 2))
boxplot(d0, ylim=lmts, xlab="x")
boxplot(d1, ylim=lmts, xlab="y")
result1 <-boxplot(d0, ylim=lmts, xlab="x")
result2<- boxplot(d1, ylim=lmts, xlab="y")
mylist <- list(result1, result2)
groupbxp <- do.call(mapply, c(cbind, mylist))
bxp(groupbxp)
4

1 回答 1

0

Like this?

set.seed(1)   # so example is reproduceable
# create example
x1=sample(50,100,10)
x2=sample(50,100,10)
y1=sample(50,100,10)
y2=sample(50,100,10)
d0<-data.frame(falling=x1,"falling-rising"=x2)  # note use of data.frame(...)
d1<-data.frame(falling=y1,"falling-rising"=y2)
lmts<-range(d0,d1)
par(mfrow = c(1, 2))
boxplot(d0, ylim=lmts, xlab="x", col=c("grey80","grey50"))
boxplot(d1, ylim=lmts, xlab="y", col=c("grey80","grey50"))
result1 <-boxplot(d0, ylim=lmts, xlab="x", plot=F)
result2<- boxplot(d1, ylim=lmts, xlab="y", plot=F)
mylist <- list(result1, result2)
groupbxp <- do.call(mapply, c(cbind, mylist))
par(mfrow=c(1,1))
bxp(groupbxp,fill=T,boxfill=c("grey80","grey50","grey80","grey50"))

To get labels other than x, y use data.frame(...) instead of matrix(...). To get colors use boxfill=... in the call to bxp(...). Note, though, that to get colors in boxplot(...) the arguments are different, sadly.

于 2014-03-20T18:31:21.290 回答