2016-05-15 83 views
0

我目前得到的数据帧按照以下称为最终Metafor包(R) - 添加多列

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) 

enter image description here

我希望能够做的就是添加更多的列不仅仅是值列(iLab的=最终$值)。

理想情况下,我想要一个能够适应多于一个额外列的解决方案,因为我打算在更多信息的基础上构建最终数据框。

另外,是否有可能在绘图线部分之后的AND之前添加额外的列?

回答

1

参数ilab也可以采用整个矩阵或数据帧(并且ilab.posilab.xpos应该是向量)。示例请参见help(forest.rma)。是的,如果您调整xlim,以便点和CI线的左侧和右侧有足够的空间,则可以将信息放置在左侧和右侧(只需使用ilab.xpos即可指定要放置各种列的位置)。