编辑:澄清一下,制作我的等值线图的功能需要" region" (州)和"价值"列,并根据值在比例上的位置简单地对区域进行颜色编码。
我想制作"价值"列动态并使图表引用动态列
我不确定我是否可以从输出对象中读取
我的滑块范围是2000-2014,列x2000-x2014。
我希望滑块更改正在绘制的数据,因此如果我选择2002-2010,它会显示数据等。
这是一个显示两年间变化百分比的等值线图,所以如果我在滑块上选择2004和2007,我希望它拉(x2007-x2004)/ x2004。我可以让它改为X2004(低< - paste0(" X",输入$ range [1]))但我真的不能做df $ low。
答案 0 :(得分:0)
如果我正确阅读了问题,那么您就可以创建一个字符串,其中包含您要访问的数据框中列的名称(low
是数据框中列的名称{{ 1}}),但您尝试使用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)
和section 6.1 of An Introduction to R。