【发布时间】:2016-09-30 07:55:32
【问题描述】:
我有 4 个数据框,我想在从 selectInput 选项中选择“未检测到夹紧杆关闭 - 错误编号 7 / 31”时打印两个数据框 a1 和 a2,但它在 selectInput 中分为两个选项,例如 Clamping未检测到关闭杆 - 错误编号 7 / 311" 和未检测到夹紧杆关闭 - 错误编号 7 / 312" 和数据框 b1 和 b2 的情况相同。
在第二个表格,即 a2 和 b2 中,我想上传文本,我可以上传它,但在选择“未检测到夹紧杆关闭 - 错误编号 7 / 31”时我没有得到表格 a1 和 a2 .
a1 <- read.csv(file.path("E:/Puma/Manuals/Smoke tables csv/AT1240E_Smoke_Meter-4.csv"), sep = "," , header = TRUE)
a2 <- read.csv(file.path("E:/Manual/error7.csv"), sep = "," , header = TRUE)
#b1<- read.csv(file.path("E:/Puma/Manuals/Smoke tables csv/AT1240E_Smoke_Meter-21.csv"), sep = "," , header = TRUE)
#b2 <- read.csv(file.path("E:/Manual/error15.csv"), sep = "," , header = TRUE)
library(shiny)
library(shinythemes)
ui <- shinyUI( fluidPage(theme=shinytheme("readable"),
titlePanel(h3("PUMA", style = "color:black")),
sidebarLayout(
wellPanel(
tags$head(
tags$style("body {background-color: pink; }")),
selectInput("error", strong("ERROR MESSAGE:", style = "color:brown" ),
choices =c("Clamping lever closing not detected-Error number 7 / 31"= c("a1", "a2"),
"Door is open (Timeout key)-Error number 15 / 100"= c("b1","b2")
),
selected = NULL
),
textInput("Possible.cause", label="Add a new Possible.cause ", value=NULL),
textInput("Check", label="Add a new Check", value=NULL),
textInput("Remedy", label="Add a new Remedy", value=NULL),
actionButton("addButton", "UPLOAD!")
),
mainPanel(tabsetPanel(
tabPanel(h2("TABLE", style = "color:brown"), verbatimTextOutput("error")),
tags$head(tags$style("#error{color:navy;
font-size: 17px;
font-style: bold;
font-family: 'Roboto';
background-color: #FFFFFF;
border-radius: 16px !important;
max-height: none;
position: absolute;
text-align: left;
spacing=l;
border-width: bold;
border-style: solid;
border-color: #f44336 !important;
}"))
),
width = 12)
)))
server <- shinyServer(function(input, output){
output$error <- renderPrint ({
get(input$error)
})
values <- reactiveValues()
values$df <- a2
row.names(a2) <- NULL
observe({
if(input$addButton > 0) {
newLine <- isolate(c(input$Possible.cause, input$Check, input$Remedy))
isolate(values$df <- rbind(as.matrix(values$df), unlist(newLine)))
write.csv(values$df,file.path("E:/Manual/error7.csv"), sep = "," ,
row.names = FALSE,append=FALSE)
}
})
})
shinyApp(ui = ui, server = server)
【问题讨论】:
标签: r csv drop-down-menu dataframe shiny