我目前有一个数据框,如下所示,名为final
final
Gms AvgPts max min Team salary position playing.status value Players
(dbl) (dbl) (dbl) (dbl) (fctr) (dbl) (fctr) (fctr) (dbl) (chr)
1 2 87.00 113 61 STK 4300 FWD Start 20.23 Tim Membrey, STK, FWD, 4300
2 4 75.50 124 42 STK 4300 MID Start 17.56 Blake Acres, STK, MID, 4300
3 7 77.43 119 50 STK 5500 RU Start 14.08 Tom Hickey, STK, RU, 5500
4 6 87.00 110 54 WCE 6200 RU Interchange 14.03 Scott Lycett, WCE, RU, 6200
5 5 71.40 89 39 STK 5200 FWD Interchange 13.73 Jack Sinclair, STK, FWD, 5200
6 3 73.33 83 68 WCE 5400 MID Start 13.58 Mark Hutchings, WCE, MID, 5400
7 7 98.71 127 83 STK 7400 MID Interchange 13.34 Sebastian Ross, STK, MID, 7400
8 7 79.14 99 53 WCE 6100 DEF Start 12.97 Jeremy McGovern, WCE, DEF, 6100
9 7 108.29 198 67 WCE 8500 FWD Start 12.74 Josh J. Kennedy, WCE, FWD, 8500
10 6 121.00 150 57 STK 9500 FWD Start 12.74 Nick Riewoldt, STK, FWD, 9500
11 6 79.17 101 59 STK 6400 MID Start 12.37 Luke Dunstan, STK, MID, 6400
12 7 84.86 104 60 STK 7000 DEF Start 12.12 Shane Savage, STK, DEF, 7000
13 7 82.14 100 45 WCE 6900 FWD Start 11.90 Jack Darling, WCE, FWD, 6900
14 7 95.29 138 76 WCE 8100 RU Start 11.76 Nic Naitanui, WCE, RU, 8100
15 7 87.43 135 53 WCE 7500 FWD Start 11.66 Mark LeCras, WCE, FWD, 7500
16 7 74.29 92 34 WCE 6400 DEF Start 11.61 Brad Sheppard, WCE, DEF, 6400
我使用以下代码行生成森林图,如下所示:
forest(x = final$AvgPts, ci.lb = final$min, ci.ub = final$max, slab = final$Players,ilab = final$value, ilab.xpos = max(final$max)+10,ilab.pos =4,yaxs="i", alim = c(min(final$min)-5, max(final$max)+5),steps = 4, xlim = c(min(final$min)-200, 2*(max(final$max)+5)), xlab = "Moneyball Points Spread", efac = 0.75-.0014*k, cex = 0.75, mgp = c(1, 1, 0),refline=mean(final$AvgPts),digits=1,col="dark blue",pch = 19,main=paste("2016 Moneyball Summary - pos =",paste(as.character(pos), collapse=", "),"\n(avg >=",points,"-- value >=",val,"-- TOG >=",time,")"))
text(min(final$min)-200, (nrow(final) + 1.5), "Player",pos=4,cex=0.75)
text(max(final$max)+10, (nrow(final) + 1.5), "Value",pos=4,cex=0.75)
text(2*(max(final$max)+5), (nrow(final) + 1.5), "Average[min,max]",pos=2,cex=0.75)
我想要做的是添加更多列而不仅仅是Value列(ilab = final $ value)。
理想情况下,我想要一个能够满足一个额外列的解决方案,因为我打算在最终数据框架上构建更多信息。
此外,是否可以在绘图线部分之前和之后添加额外的列?
答案 0 :(得分:1)
ilab
参数也可以采用整个矩阵或数据框(然后ilab.pos
和ilab.xpos
应该是向量)。有关示例,请参阅help(forest.rma)
。是的,如果您调整xlim
以便点和CI线的左侧和右侧有足够的空间,您也可以将信息放在左侧和右侧(只需使用ilab.xpos
即可指定放置各种列的位置。