【发布时间】:2016-06-03 14:43:36
【问题描述】:
我正在尝试以闪亮的方式相互绘制两个数据框变量(我是闪亮的新手,但仍在试图找出反应性)。这个想法是用户可以从下拉列表中选择任何两个变量,R 将绘制它们。首先,我不完全确定我是否可以按照我尝试的方式去做。其次,我收到一个错误:
警告:as.double 中的错误:无法将“闭包”类型强制转换为“double”类型的向量
堆栈跟踪(最内层优先): 82:xy.坐标 81:绘图。默认值 80:情节 79:渲染图[app/Plotapp2.R#39] 71:输出$绘图 4: 3:do.call 2:print.shiny.appobj 1:打印
这是代码。任何帮助将不胜感激。谢谢!
library(shiny)
All.choice = c ("Sepal.Length", "Sepal.Width","Petal.Length", "Petal.Width", "Species")
ui <- pageWithSidebar(
headerPanel("Plot 2 variables"),
sidebarPanel(
selectInput(inputId = "x",
label = "Choose the x axis",
All.choice),
selectInput(inputId = "y",
label = "Choose the y axis",
All.choice)
),
mainPanel(
plotOutput("plot")
)
)
server <- function(input, output) {
x11 = reactive({
x1 = input$x
iris$x1
})
y11 = reactive({
y1 = input$y
iris$y1
})
output$plot = renderPlot({
plot(x11,y11)
})
}
shinyApp(ui = ui, server = server)
更新:我将最后一行更改为
plot(x11(),y11())
并且错误消息更改为:需要有限的 'xlim' 值
【问题讨论】:
-
我在最后一行对 plot(x11(), y11()) 进行了更改,现在我得到的错误是:需要有限的 'xlim' 值 min(x) 中的警告:没有非- 缺少对 min 的参数;在 max(x) 中返回 Inf 警告:max 没有非缺失参数;在 min(x) 中返回 -Inf 警告:min 没有非缺失参数;在 max(x) 中返回 Inf 警告:max 没有非缺失参数;返回 -Inf 警告:plot.window 中的错误:需要有限的“xlim”值