2016-05-15 60 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即可指定要放置各種列的位置)。