[英]r shiny slider range to graph
edit: to clarify, the function to make my choropleth graph require "region" (state) and "value" columns, and simply color codes the region based on where value falls on the scale. 编辑:澄清一下,使我的波形图的功能需要“区域”(状态)和“值”列,并根据值在刻度上的位置简单地对区域进行颜色编码。
I want to make the "value" column dynamic and have the graph reference the dynamic column 我想使“值”列动态化,并让图形引用动态列
I am not sure if I can read from an output object 我不确定是否可以从输出对象读取
I have a slider range from 2000-2014, and columns x2000-x2014. 我的滑杆范围是2000-2014,列为x2000-x2014。
I want the slider to change the data being graphed, so if I choose 2002-2010 it shows that data, etc. 我希望滑块更改要绘制图形的数据,因此,如果选择2002-2010,它将显示该数据等。
It's a choropleth graph showing % change between the two years, so if I choose 2004 and 2007 on the slider I want it to pull (x2007-x2004)/x2004. 它是一个显示两个年份之间变化百分比的曲线图,因此,如果我在滑块上选择2004和2007,我希望它拉(x2007-x2004)/ x2004。 I can get it to change to X2004 (low<- paste0("X", input$range[1])) but I cant really do df$low.
我可以将其更改为X2004(low <-paste0(“ X”,input $ range [1])),但我不能真正做到df $ low。
If I read the question correctly then you are able to create a character string with the name of the column in the data frame that you want to access ( low
is the name of the column in data frame df
), but your attempts to access that column using df$low
is not working. 如果我正确阅读了该问题,则可以使用要访问的数据框中的列名创建一个字符串(
low
是数据帧df
中的列名),但是您尝试访问该字符串使用df$low
列不起作用。 Is that correct? 那是对的吗?
If so, then there is actually a fortune about this: 如果是这样,那么实际上有一笔运气:
> 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)
The answer to your question is in the bottom part of that quote and is detailed on the help page help('$')
and in section 6.1 of An Introduction to R . 您问题的答案在引号的底部,并且在帮助页面
help('$')
和An Introduction to R中的6.1节中进行了详细说明 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.