I am unable resolve the error with a shiny app to create a bar plot.The error that shows up is no argument passed.The Code is given below.
Ui.R
shinyUI(fluidPage(
titlePanel("An Overview of my skillsets"),
sidebarLayout(
sidebarPanel(
selectInput("dataset", "Select Company",
choices = c("Accenture", "Auroch", "Quintiles", "Others")),
numericInput("obs", "Number of observations to view:", 10) ),
mainPanel(plotOutput(""))
)
))
Server.R
library(shiny)
shinyServer(function(input, output) {
TechSkills <- c( "X", "Y", "Z", "A", "B", "C")
TS_ACC <-c(25,26,22,12,22,27)
TS_AUR <- c(8,6,7,5,4,7)
TS_QUIN <- c(12,12,14,24,17,27)
ACCENTURE=data.frame(TechSkills, TS_ACC)
AUROCH=data.frame(TechSkills, TS_AUR)
QUINTILES=data.frame(TechSkills, TS_QUIN)
datasetInput <- reactive({
switch(input$dataset,
"Accenture" = ACCENTURE,
"Auroch" = AUROCH,
"Quintiles" = QUINTILES,
"Others" =OTHERS)
})
output$dataset <- renderPlot({
barplot(data=dataset)
})
})
There are several things that could be wrong in this code:
So, the code should look something like that:
ui.R
shinyUI(fluidPage(
titlePanel("An Overview of my skillsets"),
sidebarLayout(
sidebarPanel(
selectInput("dataset", "Select Company",
choices = c("Accenture", "Auroch", "Quintiles", "Others")),
numericInput("obs", "Number of observations to view:", 10) ),
mainPanel(plotOutput('dataset'))
)
))
server.R
library(shiny)
TechSkills <- c( "X", "Y", "Z", "A", "B", "C")
TS_ACC <-c(25,26,22,12,22,27)
TS_AUR <- c(8,6,7,5,4,7)
TS_QUIN <- c(12,12,14,24,17,27)
ACCENTURE=data.frame(TechSkills, TS_ACC)
AUROCH=data.frame(TechSkills, TS_AUR)
QUINTILES=data.frame(TechSkills, TS_QUIN)
shinyServer(function(input, output) {
datasetInput <- reactive({
switch(input$dataset,
"Accenture" = ACCENTURE,
"Auroch" = AUROCH,
"Quintiles" = QUINTILES,
"Others" =OTHERS)
})
output$dataset <- renderPlot({
d <- datasetInput()
barplot(height=d[,2],names.arg=d[,1])
})
})
A minute too late, but here a variant with the little known function setNames
output$mybarplot <- renderPlot({
d1 = datasetInput()
barplot(setNames(d1[,2],d1[,1]))
})
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.