Ive just started using shiny and got the following basic questions.
1) The uploaded longitudinal data includes the column with Treatment names (e.g. A,B,C,D) and the other one includes corresponding numeric codes: e.g. 1,2,4,6. The coding might be different depending on the data uploaded. Each treatments is administrated on group of patients.
I want to use numeric codes to select treatments to be compared, sort of numericInput(). I need the list to be updated according to the coding in the actual dataset provided. So far I did it with numericInput() assuming the coding will be between 1 and 10 (see code below).
2) What If I want to select according to Treatment names (here A,B,C,D), which may differ among the datasets of interest?
Help much appreciated.
shinyServer(function(input, output){
## Data reactives:
uploaded_Data <- reactive({
inFile <- input $ data
if(is.null(inFile)){return(NULL)}
read.csv(file = inFile $ datapath,
header=TRUE)
output $ raw_data <- renderTable({
uploaded_Data()
})## for table
})
shinyUI(pageWithSidebar(
headerPanel(''),
sidebarPanel(
fileInput('data', 'File to upload (.csv only):',
accept=c('.csv')),
tags $ hr(),
h4('Select treatments:'),
numericInput('T1','Treatment1 code:',1, min=1, max=10, step=1),
numericInput('T2','Treatment2 code:',2, min=2, max=10, step=1)
),
## Option for tabsets:
mainPanel(
tabsetPanel(
tabPanel('Uploaded Data',
tableOutput('raw_data'))
)
)
))## overall