我有一个多行字幕的情节:
文字的当前代码:
bq1 <- bquote("Raw: "
~ mu
~ "="
~ .(format(round(mean(stepsperday$steps), digits=2), big.mark=","))
~ ", "
~ sigma
~ "="
~ .(format(round(sd(stepsperday$steps), digits=2), big.mark = ","))
~ ", median ="
~ .(format(median(stepsperday$steps), big.mark = ","))
)
bq2 <- bquote("Imputed: "
~ mu
~ "="
~ .(format(round(mean(stepsperday.imputed$steps), digits=2), big.mark=","))
~ ", "
~ sigma
~ "="
~ .(format(round(sd(stepsperday.imputed$steps), digits=2), big.mark = ",", digits = 6))
~ ", median ="
~ .(format(median(stepsperday.imputed$steps), big.mark = ","))
)
mytext <- list(bq2, bq1)
mtext(do.call(expression, mytext),side=3,line=0:1, cex=.75)
我希望2条线在各自的数据位上水平对齐 - 平均值,sd,中位数,就像它们在表格中一样。
有没有办法做到这一点?
感谢任何提示,
SFF
答案 0 :(得分:0)
根据评论,以下内容足够:
data1 <- " Raw:"
data2 <- "Imputed:"
mytext1 <- list(data2, data1)
mtext(do.call(expression, mytext1), side=3, line=0:1, adj=c(.23, .23), cex=.75)
bq1 <- bquote(" " ~ mu
~ "="
~ .(format(round(mean(stepsperday$steps), digits=2), big.mark=","))
~ " "
~ sigma
~ "="
~ .(format(round(sd(stepsperday$steps), digits=2), big.mark = ","))
~ " median ="
~ .(format(median(stepsperday$steps), big.mark = ","))
)
bq2 <- bquote(" " ~ mu
~ "="
~ .(format(round(mean(stepsperday.imputed$steps), digits=2), big.mark=","))
~ " "
~ sigma
~ "="
~ .(format(round(sd(stepsperday.imputed$steps), digits=2), big.mark = ",", digits = 6))
~ " median ="
~ .(format(median(stepsperday.imputed$steps), big.mark = ","))
)
mytext <- list(bq2, bq1)
mtext(do.call(expression, mytext), side=3, line=0:1, adj=c(.6, .6), cex=.75)
产生输出: