library(shiny)
library(shinyBS)
library(shinysky)
shinyUI (
fluidPage(
p(HTML("<A HREF=\"javascript:history.go(0)\">Reset this page</A>")),
hr(),
bsModal("expDefModal","Current experimental design",'viewDef',size="large",dataTableOutput('expDefData')),
p('Enter variable name, followed by values:'),
hotable("expDefIn"),
actionButton('addDef',"Add this variable to exp definition",styleclass='primary'),
actionButton('viewDef',"View exp definition",styleclass='primary')
)
)
library(shiny)
library(shinyBS)
library(shinysky)
shinyServer(function(input, output,session) {
NexpDefCols = 12
curVarVals <<- reactive({ # this is actually a function!
hot.to.df(input$expDefIn) })
nmsExpDef <<- c('Name........',paste0('V',1:(NexpDefCols-1)))
tmp = rep(as.numeric(NA),NexpDefCols)
expDef <<- matrix(tmp,nrow=1)
colnames(expDef) <<- nmsExpDef
warning(paste("Should be starting new session at ",date()))
observeEvent(input$addDef,{
isolate({
curVals = unlist(curVarVals())
if(!exists('fullExpDef')){
fullExpDef <<- matrix(curVals,nrow=1)
colnames(fullExpDef) = nmsExpDef
} else {
fullExpDef <<- rbind(fullExpDef,curVals)
}
})
})
## Hands on table input:
output$expDefIn <- renderHotable({
input$addDef
isolate({
tmp = rep(as.numeric(NA),NexpDefCols)
expDef <<- matrix(tmp,nrow=1)
colnames(expDef) <<- nmsExpDef
names(expDef) = nmsExpDef
return(expDef)
})
}, readOnly = FALSE)
## for modal display:
output$expDefData = renderDataTable({
input$addDef
isolate({
colnames(fullExpDef)=nmsExpDef
return(fullExpDef)
})
})
})
shinyUI (
fluidPage(
p(HTML("<A HREF=\"javascript:history.go(0)\">Reset this page</A>")),
hr(),
bsModal("expDefModal","Current experimental design",'viewDef',size="large",dataTableOutput('expDefData')),
actionButton('addDef',"Add to exp definition",styleclass='primary'),
actionButton('viewDef',"View exp definition",styleclass='primary')
)
)
server.R
library(shiny)
library(shinyBS)
shinyServer(function(input, output,session) {
NexpDefCols = 12
nmsExpDef <<- c('Name........',paste0('V',1:(NexpDefCols-1)))
tmp = rep(as.numeric(NA),NexpDefCols)
expDef <<- matrix(tmp,nrow=1)
colnames(expDef) <<- nmsExpDef
warning(paste("Should be starting new session at ",date()))
observeEvent(input$addDef,{
isolate({
curVals = 1:NexpDefCols
if(!exists('fullExpDef')){
fullExpDef <<- matrix(curVals,nrow=1)
colnames(fullExpDef) = nmsExpDef
} else {
fullExpDef <<- rbind(fullExpDef,curVals)
}
})
})
## for modal display: