title: how to make data available in Rshiny?
body: <p>I am trying to make data available in R shiny for survival analysis. In other words, some people might not have the access to upload data in R shiny. For those people, I want to provide some dataset so that they can use the data. Does anyone know how to make some data available in R shiny? This is the code: </p>
  
  <pre><code>library(shiny)
  library(datasets)
  library(survival)
  
  options(shiny.maxRequestSize = 70 * 1024 ^ 2)
  shinyUI(fluidPage(
  titlePanel("Data Visualization"),
  tabsetPanel(
  tabPanel(
    "Upload File",
    titlePanel("Uploading Files"),
    sidebarLayout(
      sidebarPanel(
        fileInput(
          'file1',
          'Choose RData File',
          accept = c(".Rdata")
        ), 
         selectInput(
           "dataset", "Select the dataset", choices = c("LUAD_RNASeq", 
     "LUSC_RNASeq")
        )
      ),
      mainPanel(
        p("Head of the data"),
        tableOutput('contents'))
    )
  ),
  tabPanel(
    "Summary",
    pageWithSidebar(
      headerPanel('Summary of Variable'),
      sidebarPanel(
        # "Empty inputs" - they will be updated after the data is 
     uploaded
        #selectInput('row', 'Row', ""),
        selectInput('col', 'Column', "", selected = "")
  
      ),
      mainPanel(
        #p("Summary for the row"),
        #verbatimTextOutput("row_summary"),
        p("Summary for the column"),
        verbatimTextOutput("col_summary")
      )
      )
    ),
    tabPanel(
      "Survival",
    plotOutput("surPlot")
  ),
  
   tabPanel(
    "Scatter Plot",
    pageWithSidebar(
      headerPanel('Scatter Plot'),
      sidebarPanel(
        selectInput('col1', 'Column1', "", selected = ""),
        selectInput('col2', 'Column2', "", selected = "")
      ),
  
      mainPanel(
        plotOutput("scaPlot")
      )
    )
  ),
  tabPanel(
    "Univariate Cox Regression",
    pageWithSidebar(
      headerPanel('Univariate Cox Regression'),
      sidebarPanel(
        selectInput('col3', 'Cox Variable', "", selected = "")
      ),
  
      mainPanel(
        verbatimTextOutput("reg_summary"),
        plotOutput("reg_Plot")
      )
    )
  ),
  tabPanel(
    "AFT Regression",
    pageWithSidebar(
      headerPanel('Log normal AFT regression'),
      sidebarPanel(
        selectInput('col4', 'AFT Variable', "", selected = "")
      ),
  
      mainPanel(
        p("To do the AFT regression, the survival time can not be 
      zero"),
        verbatimTextOutput("aft_summary")
        #plotOutput("aft_Plot")
      )
    )
  ),
  tabPanel(
    "Glmnet Analysis",
    p("To do Glmnetplot, the survival time can not be zero or NA 
  value"),
    plotOutput("GlmnetPlot")
  )
  
  )
  ))
  
  
  
  library(shiny)
  library(datasets)
  library(survival)
  library(ggplot2)
  library(survminer)
  library(GGally)
  library(glmnet)
  library(rsconnect)
  
  
  options(shiny.maxRequestSize = 70 * 1024 ^ 2)
  load_obj &lt;- function(f)
  {
      env &lt;- new.env()
  nm &lt;- load(f, env)[1]
   env[[nm]]
  }
  shinyServer(function(input, output, session) {
  
  
  data &lt;- reactive({
    req(input$file1)
    df&lt;-load_obj(input$file1$datapath)$merged.dat
  
  # Update inputs (you could create an observer with both updateSel...)
  # You can also constraint your choices. If you wanted select only 
  numeric
  # variables you could set "choices = sapply(df, is.numeric)"
  # It depends on what do you want to do later on.
  
  updateSelectInput(
    session,
    inputId = 'row',
    label = 'Row',
    choices = 1:nrow(df),
    selected = 1
  )
  updateSelectInput(
    session,
    inputId = 'col',
    label = 'Column',
    choices = names(sapply(df, is.numeric)),
    selected = names(df)[2]
  )
  updateSelectInput(
    session,
    inputId = 'col1',
    label = 'Column1',
    choices = names(sapply(df, is.numeric)),
    selected = names(df)[4]
  )
  updateSelectInput(
    session,
    inputId = 'col2',
    label = 'Column2',
    choices = names(sapply(df, is.numeric)),
    selected = names(df)[5]
  )
  updateSelectInput(
    session,
    inputId = 'col3',
    label = 'Cox Variable',
    choices = names(sapply(df, is.numeric)),
    selected = names(df)[5]
   )
  updateSelectInput(
    session,
    inputId = 'col4',
    label = 'AFT Variable',
    choices = names(sapply(df, is.numeric)),
    selected = names(df)[5]
  )
  return(df)
  
     })
  
     output$contents &lt;- renderTable({
  df&lt;-data()
  return (head(df[,1:10]))
    })
  
   output$row_summary &lt;- renderPrint({
    df&lt;-data()
    row&lt;-as.numeric(df[input$row, 2:ncol(df)])
    summary(row)
     })
  
    output$col_summary &lt;- renderPrint({
     df&lt;-data()
     column&lt;-df[,input$col]
     summary(column)
   })
  
  
   output$surPlot &lt;- renderPlot({
  
    plot.survival &lt;- function(data)
    {
      ggsurv(survfit(
        Surv(data$OS, data$status) ~ 1,
        type = "kaplan-meier",
        conf.type = "log-log"
      ),
      main = "Survival Plot(K-M estimate)")
  
  }
  
  print(plot.survival(data()))
  
  })
  
   output$scaPlot &lt;- renderPlot({
  df&lt;-data()
  column1&lt;-df[,input$col1]
  column2&lt;-df[,input$col2]
  plot(column1, column2)
    })
  
   output$reg_summary &lt;-renderPrint({
  df=data()
  column3=df[,input$col3]
  
  res.cox=coxph(Surv(df$OS,df$status) ~ column3, data=df)
  summary(res.cox)
      })
  
   output$reg_Plot &lt;- renderPlot({
  df=data()
  column3=df[,input$col3]
  res.cox=coxph(Surv(df$OS,df$status) ~ column3, data=df)
  ggsurvplot(survfit(res.cox), palette = "#2E9FDF",ggtheme = 
  theme_minimal(),data = df)
  })
  
   output$aft_summary &lt;-renderPrint({
    df=data()
    column4=df[,input$col4]
  res.aft=survreg(Surv(df$OS,df$status) ~ column4, data=df, 
   dist="lognormal")
  summary(res.aft)
  })
  
    output$GlmnetPlot &lt;- renderPlot({
    df=data()
    y1=cbind(time=df$OS,status=df$statu)
    x1 &lt;- subset(df, select = -c(bcr,OS, status))
      x1=data.matrix(x1, rownames.force = NA)
    fit1=glmnet(x1,y1,family="cox")
    plot(fit1)
     })
  
    # datasetInput &lt;- eventReactive(input$update, {
    #   switch(input$dataset,
    #          "rock" = rock,
    #          "pressure" = pressure,
    #          "cars" = cars)
    # })
  
  
    #  output$aft_Plot &lt;- renderPlot({
    #    df=data()
    #    df=df[-c(which(df$OS==0)),]
    #    column4=df[,input$col4]
    #    res.aft=survreg(Surv(df$OS,df$status) ~ column4, data=df, 
   dist="lognormal")
    #    ggsurvplot(survfit(res.aft), color = "#2E9FDF",ggtheme = 
  theme_minimal(),data = df)
    #  })
  
     })
  </code></pre>