R:带多行文字的直方图副标题:如何在列中获得表格对齐方式?
R: Histogram subtitle with mtext: how to get tabular alignment in columns?
我有一个带有 multi-line 副标题的情节:
文本的当前代码:
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、中位数,就像它们在 table.
中一样
有什么办法吗?
感谢任何提示,
sff
根据评论,以下内容就足够了:
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)
产生输出:
我有一个带有 multi-line 副标题的情节:
文本的当前代码:
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、中位数,就像它们在 table.
中一样有什么办法吗?
感谢任何提示,
sff
根据评论,以下内容就足够了:
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)
产生输出: