【发布时间】:2019-06-19 13:07:44
【问题描述】:
我正在尝试制作我的第一个闪亮的应用程序,其中接受了许多值,执行了许多计算(这取决于输入中的值和服务器函数中的值),然后绘制的输出。但是,我可以在输出中根本没有绘图(如下面的示例所示),或者只能获得 1:1 线而不显示我的数据。我不完全确定从哪里开始进行故障排除,但我认为我在进行计算和将它们输入到绘图函数中都有问题。如果您有任何指点,将不胜感激。
这是我的应用程序的简化版本:
library(shiny)
require(ggplot2)
ui<-fluidPage(
sidebarLayout(
sidebarPanel(
titlePanel("mytitle"),
sliderInput(inputId= "min", label="minratio", value=0, min=0, max=0.499),
sliderInput(inputId= "max", label="maxratio", value=1, min=0.5, max=1)
),
mainPanel(
textOutput("valoutput"),
plotOutput("distPlot",width="100%"))
)
)
server<-function(input, output){
BS = function(x) {
mini=x[1]; maxi=x[2]
ratio <-seq(from=mini,to=maxi, by=0.01)
total<-30*ratio+3
res = c(ratio,total)
}
data<-reactive({as.data.frame("mini"=as.numeric(input$min), "maxi"=as.numeric(input$max))})
output$valoutput <- renderText({BS(data())[1]})
output$distplot <- renderPlot({
d1=BS(data())[1]
d2=BS(data())[2]
ggplot()+geom_abline(intercept = 0, slope=1, colour="grey50")+geom_point(aes(x=d1, y=d2))
}, height = 350, width = 600)
}
shinyApp(ui=ui, server=server)
非常感谢!
【问题讨论】:
-
}, height = 350, width = 600)这里为什么有} -
那是
renderPlot的右括号。