Как добавить сноску, если вы используете пакет R для леса?

Пожалуйста, простите за наивный вопрос, поскольку я новичок в 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)

person Christina    schedule 01.10.2016    source источник


Ответы (1)


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, поэтому 0,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))

введите здесь описание изображения

person rawr    schedule 01.10.2016