【发布时间】:2017-05-30 10:54:08
【问题描述】:
我在项目中使用 Rstudio 和 Shiny。
我定义了一个变量res,它包含具有多行和多列的数据框,然后我制作了一个图,它的 x y 和颜色是来自res 数据框的数据。
我的问题是,当我运行它时,如果我写我希望 x 轴输入变量值(input$SelInp),我没有得到数据框值,而是只得到列名。
如果我更改代码以直接从数据框 (res$some_column_name) 获取值,我会得到正确的值。
ui.R
selectInput("SelInp",
label = "Choose one:",
choices = colnames(res)
)
服务器.R
output$plt = renderPlot({
qplot(data = res,
x = input$SelInp, #this only returns a column name
y = res$loan_amnt, # this returns correct values from column loan_amt
ylab = "some y axis",
xlab = "some x axis",
main="Our Chart")
}
)
所以,我想提前获得input$SelInp 中的值
【问题讨论】: