#install.packages("shinythemes")
#install.packages("shinyjs")
install.packages("DT")
install.packages("reshape2")
library(shiny)
library(shinythemes)
library(shinyjs)
library(DT)
library(reshape2)
data <- read.csv("C:/Users/Kanchan/Desktop/timeforcompletion.csv")
server <- function(input, output, session) {
dat <- reactive ({
row1 <- row.names (data[data$Chromosomes == input$select &
data$Data.per.chromosomes == input$select1 &
data$CPU.worker == input$select2,])
row1 <- as.numeric(row1)
out1 <- data$Num.of.workers[row1]
out2 <- data$Time.to.complete..Mins.[row1]
val <- data.frame(Name = c("Num of workers","Time.to.complete..Mins."), Value = c(out1,out2)
,stringsAsFactors = FALSE)
#require(reshape2)
#melt(val)
return(val)
})
output$mytable <- DT::renderDataTable(dat())
}
ui <- fluidPage(theme = shinytheme("cosmo"),
shinyjs::inlineCSS(list(body = "color:DarkBlue")),
titlePanel("WQ-MAKER"),
sidebarLayout(
sidebarPanel(
"Sidebar"
), #endsidebarpanel
mainPanel(
selectInput("select", label = h3("Chromosomes"),
choices = list("12" = 1, "24" = 2),
selected = 1),
selectInput("select1", label = h3("Data per chromosomes"),
choices = list("100000" = 1, "200000" = 2, "1000000" = 3),
selected = 1),
selectInput("select2", label = h3("CPU per worker"),
choices = list("4" = 1),
selected = 1),
#textOutput("text1")
hr(),
DT::dataTableOutput("mytable")
)#end mainpanel
)# end sidebarlayout
)
shinyApp(ui = ui, server = server)
Die Eingabedatei sieht wie folgt aus:Shiny App: Warnung: Fehler in data.frame: Argumente implizieren unterschiedliche Anzahl der Zeilen: 2, 0
Chromosomes Data per chromosomes CPU/worker Num of workers Time to complete (Mins)
12 100000 4 3 16.8333
24 100000 4 3 23.4167
12 200000 4 3 23.1333
12 1000000 4 3 54.7667
12 1000000 4 7 17.5444
Ich verstehe, dass das Problem mit dem Ausgang $ ist mein Tisch. Bitte helfen Sie mir, den Code zu korrigieren, um eine Ausgabe zurückzugeben, die 2 Werte anzeigt.
Num der Arbeitnehmer: xxx Zeit bis zur Fertigstellung: xxxx
BTW, hier ist ein guter Artikel zum Debuggen von Shiny-Apps. FYI, ich habe plain old 'cat()' benutzt, um dieses zu debuggen. http://shiny.rstudio.com/articles/debugging.html – Teajay
Danke T.J :) Die App funktioniert jetzt ganz gut, und der Debugging-Tipps Artikel ist ziemlich cool. –
@KanchanSonthalia Großartig! Klicken Sie in diesem Fall bitte auf das grüne Häkchen links neben dieser Antwort, um es zu akzeptieren, und wir erhalten beide Ansehenspunkte. – Teajay