闪亮的应用程序以宽格式显示数据(values $ data)

时间:2019-01-08 17:46:36

标签: shiny shinydashboard shiny-server

是否可以将values$data的表显示为宽格式(到目前为止,我只能以长格式显示该表。非常感谢您。我尝试将values$data转换为data.frame来操作它,但是我没有成功。

library(reshape)
library(shiny)
ui <- fluidPage(fluidPage(
  titlePanel("Echo Z-Score"),
  sidebarLayout(

    sidebarPanel(
      helpText("This App returns BSA, Z-scores & ranges 
               based on your inputs & PHN data."),            
      br(),            
      numericInput("Weight",
                   label = h6("Enter Weight (Kg)"), value = 00
      ),
      br(),     
      numericInput("Height",
                   label = h6("Enter Height (Cm)"), value= 00
      ),
      br(),   
      br(),

      br(),
      br(),            
      actionButton("action_Calc", label = "Calculate") ),

    mainPanel(
      tabsetPanel(
        tabPanel("Output", br(),br(),
                 p(h5("Your entered values:")),
                 textOutput("text_Weight"),
                 textOutput("text_Height"),
                 br(), br(),
                 p(h5("Calculated BSA:")),
                 textOutput("text_BSA")),
                 tableOutput("table1") ,

        tabPanel("Table", tableOutput("table1"))

我的服务器代码:

library(reshape)
shinyServer(function(input, output) {

  zs =read.csv("new_zs.csv") #reads the csv file
  values <- reactiveValues() 

  output$text_Weight <- renderText({input$action_Calc
    paste("Weight =", isolate(input$Weight))            })

  #Second output display height 
  output$text_Height <- renderText({input$action_Calc
    paste("Height =", isolate(input$Height))            })

  observe({ input$action_Calc  
    values$bsa <- isolate({
      (input$Weight)^0.5378 *
      (input$Height)^0.3964 * 0.024265
                         }) 
    output$text_BSA = renderText({ if (input$action_Calc ==0) ""
      else 
        paste("BSA =", values$bsa)})
    })
    values$parms <<- isolate({ (zs$zscore*zs$SD +zs$Mean)*(values$bsa)^0.5 })
    values$data <<- data.frame(zs$Parameter, zs$zscore, values$parms)
    })
  output$table1 <- renderTable(values$data)
})

0 个答案:

没有答案