gpt4 book ai didi

r - 如果您使用的是 Forestplot R 包,如何添加脚注?

转载 作者:行者123 更新时间:2023-12-04 12:37:38 24 4
gpt4 key购买 nike

请原谅这个幼稚的问题,因为我是 R 的新手。我使用我在 R 博客上看到并改编的代码生成了一个森林图。我想添加一个脚注,但我不知道该怎么做。我看过不同的代码,但我不知道哪一个合适。非常感谢任何建议!谢谢!

森林图代码如下:

library(ggplot2)
library(grid)
library(gridExtra)
library(xtable)
library(plyr)
library(MASS)
library(reshape2)

d1 <- read.csv("/view/name_view/vob/folder/subfolder/forestTAF.csv", stringsAsFactors=FALSE)

#Format data so column labels and columns match required graphical output
subgps <- c(4,5,8,9,12,13,16,17,20,21,24,25,28,29)

#Combine the rest of the columns in the table
tabletext <- cbind(c("Change due to", d1$Variable),
c("PK Measures", d1$PK.Measures),
c("Recommendation", d1$Recommendation))

#Load forestplot package
library(forestplot)

#Create forest plot
png(filename="forestTAF.png",width=1600, height=640)
forestplot(labeltext=tabletext, graph.pos=3, align=c("l", "c", "l"),
mean=c(NA,d1$Point.Estimate),
lower=c(NA,d1$Low), upper=c(NA,d1$High),
title="Drugname \nFold Change and 90% CI",
xlab="Change Relative to Reference (i.e., without interaction)",
txt_gp=fpTxtGp(label=gpar(cex=1.25),
ticks=gpar(cex=1.1),
xlab=gpar(cex = 1.2),
title=gpar(cex = 1.2)),
col=fpColors(box="black", lines="black"),
zero=1, cex=0.9, lineheight = "auto", boxsize=0.5, colgap=unit(6,"mm"),
lwd.ci=2, ci.vertices=TRUE, ci.vertices.height = 0.4)

最佳答案

grid::gridtext是一种选择

library('forestplot')

## ?forestplot

row_names <- list(list("test = 1", expression(test >= 2)))
test_data <- data.frame(coef=c(1.59, 1.24),
low=c(1.4, 0.78),
high=c(1.8, 1.55))
forestplot(row_names, test_data$coef, test_data$low, test_data$high,
zero = 1, cex = 2, lineheight = "auto", xlab = "Lab axis txt")
grid::grid.text哪里 "npc"grid::unit是标准化的 0,1 坐标,因此 .05 将是整个图像的 5%
x <- unit(.05, 'npc')
y <- unit(.05, 'npc')
grid.text('A footnote', x, y, gp = gpar(fontsize=10, font = 3))

或者,您可以使用 grid::grid.locator它允许您指向并单击您想要的位置。
g <- grid.locator('npc')
grid.text('A footnote', g$x, g$y, gp = gpar(fontsize=10, font = 3))

enter image description here

关于r - 如果您使用的是 Forestplot R 包,如何添加脚注?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39801985/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com