I am having serious trouble on how to add a column to a grouped forestplot. I want the estimate column for each corresponding time point on the right hand side of the graph and each unique outcome with the estimates for each time point. Any help would be SUPER appreciated! I am not sure how to reformat my data or how to go about this.
Thanks
This is my dataframe
> dput(results_1_2_3_4_5_subset1)
structure(list(Outcome = c("Entorhinal", "Hippocampus", "Amygdala",
"Fusiform", "Lingual", "Parahippocampal"), outcome = c("Entorhinal (Braak I)",
"Hippocampus (Braak II)", "Amygdala (Braak III)", "Fusiform (Braak III)",
"Lingual (Braak III)", "Parahippocampal (Braak III)"), b.x = c(-0.000605859,
0.012952928, 0.012294486, 0.013473204, 0.001821691, -0.020062775
), se.x = c(0.013873659, 0.01136426, 0.010911751, 0.011322333,
0.012394498, 0.014363217), pval.x = c(0.965167637, 0.254371679,
0.25986096, 0.234059306, 0.88315116, 0.162468816), beta_doubling.x = c(-0.000419949457666868,
0.00897828552319597, 0.00852188830733372, 0.00933891336570898,
0.00126269998050143, -0.0139064559254586), lci_doubling.x = c(-0.0192682651926711,
-0.00646083984197835, -0.00630247259628572, -0.00604325129906024,
-0.0155760742520841, -0.0334198697254071), uci_doubling.x = c(0.0184283662773373,
0.0244174108883703, 0.0233462492109532, 0.0247210780304782, 0.018101474213087,
0.00560695787448996), coef.3 = c(-0.000419949457666868, 0.00897828552319597,
0.00852188830733372, 0.00933891336570898, 0.00126269998050143,
-0.0139064559254586), lower.3 = c(-0.0192682651926711, -0.00646083984197835,
-0.00630247259628572, -0.00604325129906024, -0.0155760742520841,
-0.0334198697254071), upper.3 = c(0.0184283662773373, 0.0244174108883703,
0.0233462492109532, 0.0247210780304782, 0.018101474213087, 0.00560695787448996
), est3 = c("-0.0004 (-0.02, 0.02)", "0.01 (-0.01, 0.02)", "0.01 (-0.01, 0.02)",
"0.01 (-0.01, 0.02)", "0.001 (-0.02, 0.02)", "-0.01 (-0.03, 0.01)"
), Timepoint.x = c(3, 3, 3, 3, 3, 3), b.y = c(-0.001675819, -0.023670467,
-0.001111456, 0.012264843, 0.000635353, -0.006410602), se.y = c(0.013494176,
0.014819246, 0.012429164, 0.012026395, 0.011834151, 0.013141676
), pval.y = c(0.901166148, 0.110203575, 0.928745593, 0.307810512,
0.957183684, 0.625686521), beta_doubling.y = c(-0.00116158921497879,
-0.0164071174635872, -0.000770402592716435, 0.00850134134546038,
0.000440393140610303, -0.00444349070199195), lci_doubling.y = c(-0.019494351309803,
-0.0365400778861187, -0.0176562729600181, -0.00783733975617806,
-0.0156371113233322, -0.0222973574097673), uci_doubling.y = c(0.0171711728798454,
0.0037258429589443, 0.0161154677745852, 0.0248400224470988, 0.0165178976045528,
0.0134103760057834), coef.4 = c(-0.00116158921497879, -0.0164071174635872,
-0.000770402592716435, 0.00850134134546038, 0.000440393140610303,
-0.00444349070199195), lower.4 = c(-0.019494351309803, -0.0365400778861187,
-0.0176562729600181, -0.00783733975617806, -0.0156371113233322,
-0.0222973574097673), upper.4 = c(0.0171711728798454, 0.0037258429589443,
0.0161154677745852, 0.0248400224470988, 0.0165178976045528, 0.0134103760057834
), est4 = c("0.00 (-0.02, 0.02)", "-0.02 (-0.04, 0.004)", "-0.001 (-0.02, 0.02)",
"0.01 (-0.01, 0.02)", "0.0004 (-0.02, 0.02)", "-0.004 (-0.02, 0.01)"
), Timepoint.y = c(4, 4, 4, 4, 4, 4), b = c(-0.064953436, -0.06092979,
-0.06093406, -0.021297946, 0.012673571, -0.041319816), se = c(0.018300301,
0.012544904, 0.01253181, 0.009075243, 0.011827807, 0.017608535
), pval = c(0.000386243, 1.19216372849548e-06, 1.15999552349874e-06,
0.018934484, 0.283941804, 0.018946657), beta_doubling = c(-0.0450222910310809,
-0.0422333121506095, -0.0422362718890705, -0.014762611221618,
0.00878465000627629, -0.0286407139616557), lci_doubling = c(-0.0698845030325156,
-0.0592764232330801, -0.0592615938759439, -0.0270919502543769,
-0.00728423569926779, -0.0525631144841763), uci_doubling = c(-0.0201600790296461,
-0.025190201068139, -0.0252109499021972, -0.00243327218885906,
0.0248535357118204, -0.00471831343913513), coef.5 = c(-0.0450222910310809,
-0.0422333121506095, -0.0422362718890705, -0.014762611221618,
0.00878465000627629, -0.0286407139616557), lower.5 = c(-0.0698845030325156,
-0.0592764232330801, -0.0592615938759439, -0.0270919502543769,
-0.00728423569926779, -0.0525631144841763), upper.5 = c(-0.0201600790296461,
-0.025190201068139, -0.0252109499021972, -0.00243327218885906,
0.0248535357118204, -0.00471831343913513), est5 = c("-0.05 (-0.07, -0.02)",
"-0.04 (-0.06, -0.03)", "-0.04 (-0.06, -0.03)", "-0.01 (-0.03, -0.002)",
"0.01 (-0.01, 0.02)", "-0.03 (-0.05, -0.005)"), Timepoint.x = c(5,
5, 5, 5, 5, 5), outcome.y = c("Entorhinal", "Hippocampus", "Amygdala",
"Fusiform", "Lingual", "Parahippocampal"), coef.1 = c(-0.0063769540611515,
-0.00998131940006321, -0.00935748693755926, 0.0025646445680718,
0.0063769540611515, -0.0149026643820388), lower.1 = c(-0.0273793136321178,
-0.0277258872223978, -0.0459556580711244, -0.0152492379723188,
-0.0141402024834229, -0.0387469273933009), upper.1 = c(0.0146254055098148,
0.00783256314032738, 0.0272406841960059, 0.0203092123904064,
0.0268941106057259, 0.00894159862922329), est1 = c("-0.01 (-0.03, 0.01)",
"-0.01 (-0.03, 0.01)", "-0.01 (-0.05, 0.03)", "0.003 (-0.02, 0.02)",
"0.01 (-0.01, 0.03)", "-0.01 (-0.04, 0.01)"), Timepoint.y = c(1,
1, 1, 1, 1, 1), coef.2 = c(-0.00526791857225558, 0.0210716742890223,
0.00499065970003161, -0.0105358371445112, 0.012476649250079,
-0.0307064200988056), lower.2 = c(-0.0541347948017317, -0.0183684002848385,
-0.0347959884641093, -0.0569766982420275, -0.0833856058213614,
-0.0792267227380017), upper.2 = c(0.0436682723752766, 0.0605117488628832,
0.0448466225822285, 0.0359743386710612, 0.108338904321519, 0.0178138825403906
), est2 = c("-0.01 (-0.05, 0.04)", "0.02 (-0.02, 0.06)", "0.005 (-0.03, 0.04)",
"-0.01 (-0.06, 0.04)", "0.01 (-0.08, 0.11)", "-0.03 (-0.08, 0.02)"
), Timepoint = c(2, 2, 2, 2, 2, 2), Stage = c(1, 2, 3, 3, 3,
3)), row.names = c(9L, 13L, 2L, 12L, 21L, 27L), class = "data.frame")
Code
tt1=cbind(results_1_2_3_4_5_subset2$outcome)
forestplot <- forestplot(tt1, mean = cbind(results_1_2_3_4_5_subset2$coef.1,results_1_2_3_4_5_subset2$coef.2,results_1_2_3_4_5_subset2$coef.3,results_1_2_3_4_5_subset2$coef.4,results_1_2_3_4_5_subset2$coef.5),
lower = cbind(results_1_2_3_4_5_subset2$lower.1, results_1_2_3_4_5_subset2$lower.2,results_1_2_3_4_5_subset2$lower.3,results_1_2_3_4_5_subset2$lower.4,results_1_2_3_4_5_subset2$lower.5),
upper = cbind(results_1_2_3_4_5_subset2$upper.1, results_1_2_3_4_5_subset2$upper.2,results_1_2_3_4_5_subset2$upper.3,results_1_2_3_4_5_subset2$upper.4,results_1_2_3_4_5_subset2$upper.5),
lwd.xaxis=1,
xlog=FALSE,
graph.pos = 2,
zero = 0,
lwd.zero = 1,
boxsize = 0.095,
lty = 1,
col = fpColors(lines=c("magenta","purple","black","blue","red"),box=c("magenta","purple","black","blue","red"),zero="black"), ##lines changess colour of CI
legend = c("Childhood","Early adulthood","45-60 y","60-68 y","68-81 y"),
lwd.ci = 1, ##thickness of the CI line,
xticks = c(-0.4,-0.2,0,0.2,0.4),
xlab ="SD change per doubling in genetic liability for AD (95% CI)",las = 10,
is.summary = FALSE,
txt_gp = fpTxtGp(xlab = gpar(cex=0.75),##changes font size of xlabel
ticks = gpar(cex=0.75),
legend=gpar(cex=0.70),
label = list(gpar(cex=0.75),
gpar(0.75))),
hrzl_lines=list("2" = gpar(lty=2, lwd=0.5), "3" = gpar(lty=2, lwd=0.5),"4" = gpar(lty=2, lwd=0.5), "5" = gpar(lty=2, lwd=0.5),"6" = gpar(lty=2, lwd=0.5),"7" = gpar(lty=2, lwd=0.5),"8" = gpar(lty=2, lwd=0.5),"9" = gpar(lty=2, lwd=0.5)),
legend_args=fpLegend(pos = list(x=0.5,y=-0.11, "inset"=c(-1,1), "align"="horizontal"), gpar(lwd=0.5, lty=1),padding=unit(ifelse(!is.null(forestplot), 0.6, 0.6), "mm")))
forestplot
dev.off()