楼主: suzhzh
562 1

[问答] How to display the simulated data X in the main panel? [推广有奖]

学科带头人

53%

还不是VIP/贵宾

-

威望
0
论坛币
14505 个
通用积分
756.9486
学术水平
70 点
热心指数
87 点
信用等级
52 点
经验
30444 点
帖子
3232
精华
0
在线时间
1281 小时
注册时间
2009-9-18
最后登录
2024-2-27

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如题, 如何才能在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
二维码

扫码加我 拉你入群

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

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

关键词:Simulated simulate Display Panel disp

沙发
suzhzh 发表于 2019-12-31 12:13:53 |只看作者 |坛友微信交流群
没有人能帮忙看看吗?谢谢

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-30 23:28