Quite new to shiny, can get the server to pop up - but only the drop down box will appear (no plot). Also, there a way to see each code concurrently on the same plot?
Current Script:
ui <- fluidPage(
titlePanel("sample Title"),
sidebarLayout(
sidebarPanel(
selectInput("code", "Code:",
choices=colnames(stocks[2:ncol(stocks)])),
hr(),
helpText("Sample Heading") +
),
mainPanel(
plotOutput("samplePlot") +
)
)
)
server <- function(input, output) {
output$samplePlot <- renderPlot(
ggplot(data = stocks, aes_string(x = 'date', y = input$code)) +
geom_point() + geom_line() +
xlab('Sample X') + ylab('Sample Y')
)
}
shinyApp(ui, server)
SampleFile:
date code closeprice volume company
1/2/18 ABC 3.00 300 ABC Co
1/3/18 ABC 3.01 301 ABC Co
1/4/18 ABC 3.02 302 ABC Co
1/2/18 DEF 3.00 305 DEF Co
1/3/18 DEF 3.03 308 DEF Co
1/4/18 DEF 3.04 309 DEF Co
I think it's just the + signs in your ui that is messing things up. This should work:
ui <- fluidPage(
titlePanel("sample Title"),
sidebarLayout(
sidebarPanel(
selectInput("code", "Code:",
choices=colnames(stocks[2:ncol(stocks)])),
hr(),
helpText("Sample Heading")
),
mainPanel(
plotOutput("samplePlot")
)
)
)
server <- function(input, output) {
output$samplePlot <- renderPlot(
ggplot(data = stocks, aes_string(x = 'date', y = input$code)) +
geom_point() + geom_line() +
xlab('Sample X') + ylab('Sample Y')
)
}
shinyApp(ui, server)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.