'How to create a fractional factorial design in RShiny?
I would like to create an app that allows me to obtain an fractional factorial design. My app asks the user to enter as many attributes (factors) and levels as he wants (so he could enter a different number of levels for each factor). at this point pushing the button should get the orthogonal factorial design. unfortunately I didn't find any articles explaining how to create it IN A SHINY APP. I realized that the function to use would be oa.design but i can't set it in my app. this is my code
library(shiny)
library(DoE.base)
ui<- shiny::navbarPage(
"SHINY APP", id = 'inTabset',
shiny::tabPanel("1", value = "params", #Design settings tab
shiny::sidebarLayout(
shiny::sidebarPanel( #Inputs sidebar panel
shiny::numericInput('ats', "Number of attributs", 0),
shiny::uiOutput('dynamic'),
shiny::actionButton('loadats','Salva'),
htmltools::hr(),
shiny::uiOutput('savebut'),
htmltools::hr(),
shiny::uiOutput('saveopt')
),
shiny::mainPanel(
shiny::verbatimTextOutput('levelsnumber'),
shiny::uiOutput('gobut')
)
)
)
)
server<- function(input, output, session){
values <- shiny::reactiveValues()
output$dynamic <- shiny::renderUI({
tags <- htmltools::tagList()
for (i in seq_len(input$ats)) {
tags[[i]] <- shiny::numericInput(paste0('at', i),
paste0('Number levels ', i),
0)
}
tags
})
shiny::observeEvent(input$loadats, {
nats <- input$ats
levels <- c()
for (i in seq_len(nats)){
levels <- append(levels, eval(parse(text = paste0("input$at",i))))
}
values$levels <- levels
values$nats <- nats
output$levelsnumber <- shiny::renderPrint({
cat("SCHEMA \nNumbers attributes: ", values$nats, "\nNumbers levels: ", values$levels)
})
})
# Button to create the design matrix
output$gobut <- shiny::renderUI({
shiny::actionButton("go", "Fractional factorial design")
})
}
shinyApp(ui=ui,server=server)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
