2016-02-02 132 views
0

編輯:爲了澄清,使我的等值線圖需要「區域」(狀態)和「值」列的函數,並根據值落在該範圍上的區域對區域進行顏色編碼。r閃亮的滑塊範圍到圖

我想使「值」列動,有圖引用動態列

我不知道我是否可以從輸出對象中讀取

我從2000-滑塊範圍2014年和專欄x2000-x2014。

我想滑塊以更改圖表繪製數據,所以如果我選擇2002-2010它表明,數據等

這顯示兩年%之間變化的等值線圖,所以如果我選擇2004年和2007年我希望它拉(x2007-x2004)/ x2004滑塊。我可以把它改成X2004(低< - paste0(「X」,輸入$ range [1])),但我真的不能做df $ low。

回答

0

如果我正確地閱讀了這個問題,那麼您可以創建一個字符串,其中包含您想要訪問的數據框中的列名(low是數據框df中列的名稱),但您的嘗試使用df$low訪問該列不起作用。那是對的嗎?

如果是這樣,那麼實際上是這個財富:

> library(fortunes) 
> fortune('toad') 

The problem here is that the $ notation is a magical shortcut and 
like any other magic if used incorrectly is likely to do the 
programmatic equivalent of turning yourself into a toad. 
    -- Greg Snow (in response to a user that wanted to access a 
     column whose name is stored in y via x$y rather than x[[y]]) 
     R-help (February 2012) 

的回答你的問題是在報價的底部和幫助頁面help('$')上和section 6.1 of An Introduction to R詳述。