кнопка отправки не работает в блестящем приложении - PullRequest
0 голосов
/ 27 апреля 2018

Я приложил свой код. Он не работает. Я хочу выполнить кнопку отправки, при отправке должен напечатать то, что введено в интерфейсе

server.r: -

install.packages("shiny")
library(shiny)
shinyServer(function(input,output){
output$txt1 <-renderText({
paste("state name is as :", input$text1)
 })
output$txt2 <-renderText({
paste("revenue is as :", input$text2)
 })

output$txt3 <-renderText({
paste("rate of growth :", input$text3)
})

output$txt4 <-renderText({
paste("state own tax :", input$text4)
})
output$txt5 <-renderText({
paste("revnue buoyancy :", input$text5)
})

output$txt6 <-renderText({
input$submit1
 })



} )

ui.r
install.packages("rshiny")
library(shiny)
shinyUI(fluidPage(
titlePanel("Demo Interface"),

sidebarLayout(
sidebarPanel(
  textInput("text1", "STATE:",value = " "),
  textInput("text2", "REVNUE:",value =" "),
  numericInput("text3", "RATE OF GROWTH:",value = " "),
  numericInput("text4", "STATES OWN TAX",value = " "),
  numericInput("text5", "REVENUE BUOYANCY",value = " "),
  actionButton("submit1", strong("Submit"))
),
mainPanel(
verbatimTextOutput("txt1"),
verbatimTextOutput("txt2"),
verbatimTextOutput("txt3"),
verbatimTextOutput("txt4"),
verbatimTextOutput("txt5"),
verbatimTextOutput("txt6")

 )
 )
 ))

1 Ответ

0 голосов
/ 27 апреля 2018

Что-то вроде этой работы:?

library(shiny)

ui <- fluidPage(titlePanel("Demo Interface"),

                sidebarLayout(
                  sidebarPanel(
                    textInput("text1", "STATE:",value = " "),
                    textInput("text2", "REVNUE:",value =" "),
                    numericInput("text3", "RATE OF GROWTH:",value = " "),
                    numericInput("text4", "STATES OWN TAX",value = " "),
                    numericInput("text5", "REVENUE BUOYANCY",value = " "),
                    actionButton("submit1", strong("Submit"))
                  ),
                  mainPanel(
                    verbatimTextOutput("txt1"),
                    verbatimTextOutput("txt2"),
                    verbatimTextOutput("txt3"),
                    verbatimTextOutput("txt4"),
                    verbatimTextOutput("txt5"),
                    verbatimTextOutput("txt6")

                  )
                )
)

server <- function(input,output){

  mdata <- eventReactive(input$submit1,{
    data <- c(input$text1,input$text2,input$text3,input$text4,input$text5)
    data[is.na(data)] <- ""
    data
  })

  output$txt1 <- renderText({paste("state name is as :", mdata()[1])})
  output$txt2 <-renderText({paste("revenue is as :",  mdata()[2])})
  output$txt3 <-renderText({ paste("rate of growth :",  mdata()[3])})
  output$txt4 <-renderText({paste("state own tax :",  mdata()[4])})
  output$txt5 <-renderText({paste("revenue buoyancy :",  mdata()[5])})
}


shinyApp(ui, server)

enter image description here

...