我在 R 中使用闪亮的包从用户那里获取输入并将 X 和 Y 变量相互绘制为线图。没有显示错误。除了图表之外的所有内容都显示了。请有人帮忙为什么不显示图表.这是ui.r 文件
library(shiny) # load the shiny package
setwd("C:/indiahacks2")
dat<-read.csv("final.csv")
# Define UI for application
shinyUI(fluidPage(
# Header or title Panel
titlePanel(h4('Impulse Response on VAR MODEL', align = "center")),
# Sidebar panel
sidebarPanel(
selectInput("Impulse", label = "1. Select the Impulse Variable",
choices = names(dat)),
selectInput("Response", label = "1. Select the Response Variable",
choices = names(dat)),
sliderInput("Lag", "2. Select the number of histogram BINs by using the slider below", min=0, max=25, value=10),
radioButtons("colour", label = "3. Select the color of histogram",
choices = c("Green", "Red",
"Yellow"), selected = "Green")
),
# Main Panel
mainPanel(
textOutput("text1"),
textOutput("text2"),
textOutput("text3"),
textOutput("text3"),
plotOutput("myhist")
)
)
)
服务器.r
library(shiny) # Load shiny package
dat<-read.csv("final.csv")
shinyServer(
function(input, output) {
output$text1 <- renderText({
colm = as.numeric(input$Impulse)
paste("Impulse Variable is", names(dat[colm]))
})
output$text2 <- renderText({
paste("Color of plot is", input$radio)
})
output$text3 <- renderText({
paste("Number of Lags is", input$Lag)
})
output$text4 <- renderText({
colm = as.numeric(input$Response)
paste("Response Variable is", names(dat[colm]))
})
output$myhist <- renderPlot(
{
colm = as.numeric(input$Impulse)
colm1 = as.numeric(input$Response)
plot(dat[,colm],dat[,colm1])})
})