全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
774 1
2019-12-26
如题, 如何才能在shiny main panel上看到我simulated 数据x?

代码如下:
ui <- fluidPage(
  titlePanel("Lesson 1 Introduction to Sample Size Calcuation in Clinical Trials"),
  sidebarLayout(
    sidebarPanel(
    #Select the sample size;
    selectInput(inputId="size", label="Sample size you choose", choices=seq(1, 30, by=1), selected=5),
    numericInput("seed","Seed Number to generate Sample is", 12345, min=0, max=20000),
    numericInput("simn", "Number of Trials", 2, min=1, max=1000)
    ),


    mainPanel(
      h1("Why should we consider Sample Size in Clinical Trials?"),
      h3("Because insufficient size will make an effective drug fail to show efficacy", style = "font-family: 'times'; font-si16pt"),
      br(),
      br(),
      strong("An example"),
      br(),  
      em("Suppose a new tech which improves the quality, which is measured by use of the quality in kg, of the product.
      The previous standard is mean of 3kg, while now the tech patent owner claims to the quality could reach to 5kg and the standard deviation is 3.
      Therefore, we would like to testify this statement by use of a trial"),
      br(),
      code("it could be easily calculate out to reach a 80% power, we need to sample 16, so if we sample 10, 12, 14, let's see what the power is" ),
      div("This could be shown in the example", style = "color:blue"),
      br(),
      p("span does the same thing as div, but it works with",
        span("groups of words", style = "color:blue"),
        "that appear inside a paragraph."),

      #Output the results you want with font of BOLD;
      strong(textOutput("size")),

      #output the number of trials;
      strong(textOutput('n_trial')),

      #The seed used to generate the data is;
      strong(textOutput('seed')),
      #Output the sample simulated data;
      DT::dataTableOutput("dat")
    )
  )
)

server<-function(input, output){
        if(!require(DT)) install.packages("DT")
        library(DT)

output$size <- renderText({
    paste("You have selected sample size is", input$size)
  })

  output$n_trial<-renderText({
          paste("You have done", input$simn, "trials")
  })


  output$seed<-renderText({
          paste("The seed used to generate the data is", is.numeric(input$seed))
  })
            
  output$dat<-DT::renderDataTable(DT::datatable({
    x<-matrix(0, nrow=input$simn, ncol=input$size)
          for(i in 1:input$simn){
                  x[i,]<-rnorm(input$size,0,1)
          }   
    x
  }))
         
}

shinyApp(ui=ui, server=server)
Q&A.zip
大小:(1.25 KB)

 马上下载

本附件包括:

  • Q&A.R

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2019-12-31 12:13:53
没有人能帮忙看看吗?谢谢
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群