IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

R Discussion :

Aide sur Shiny (R)


Sujet :

R

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Février 2023
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Février 2023
    Messages : 1
    Par défaut Aide sur Shiny (R)
    Bonjour,

    Je suis débutant sur shiny et plus généralement sur R, j'aimerais avoir une aide sur un problème que je rencontre. En fait , je souhaite que mon code intéragisse avec mes radiobuttons mais je ne sais pas comment faire ce lien.
    L'interface est celle que j'ai mis en PJ. Mes 3 bouttons sont int, conf et cat.

    Lorsqu'il n y aucun bouton d'activer, la ligne ci-dessous est avec 000, lorsque que le boutton int est actif et les autres inactifs je veux 100. Avec cette même logique, lorsque les 3 sont actifs, je veux 111.

    fullgrid <- genDefGrid(def, pl, pw, 000)

    J'aimerais donc modifier fullgrid en fonction de ce que l'utilisateur choisi. Si vous avez des idées n'hesitez pas
    Merci

    Le code shiny complet :
    library(shiny)
    library(ggplot2)
    library(gridExtra)

    # Define UI
    ui <- fluidPage(

    # Application title
    titlePanel("Defect map analysis"),
    # Defect table selection
    fluidRow(
    column(2,
    selectInput("prod", "Select a product:",
    tb_prod[,"id"])
    ),
    column(1, textOutput("lineid")),
    column(1, textOutput("pdate")),
    column(1, textOutput("ptime")),
    column(1, textOutput("pfamily")),
    column(1, textOutput("pac")),
    column(1, textOutput("pcf")),
    column(1, textOutput("pl")),
    column(1, textOutput("pw")),

    ),
    # First graph
    fluidRow(
    column(2,
    wellPanel(
    radioButtons("rbGraph1", "Graph:",
    choiceNames = list("product", "defect"),
    choiceValues = list("prod", "def"),
    inline = T
    ),
    radioButtons("rbDefect1", "Defect:",
    choiceNames = list("point", "rect"),
    choiceValues = list("point", "rect"),
    inline = T
    ),
    radioButtons("rbMain1", "Main:",
    choiceNames = list("T+B", "T", "B"),
    choiceValues = list("D", "T", "B"),
    inline = T
    ),
    checkboxGroupInput("cbWeight1", "Weight:",
    choiceNames = list("int", "conf", "cat"),
    choiceValues = list("int", "conf", "cat"),
    inline = T
    ),
    fluidRow(
    column(6,
    numericInput("numIn1", "Opacity:", 1, min = 1, width = 100)
    ),
    column(6,
    textInput("txtIn1", "Max value:", "display max", width = 100)
    )
    )
    )
    ),
    column(10,
    plotOutput("prodPlot1")
    )
    ),
    # Second graph
    fluidRow(
    column(2,
    wellPanel(
    radioButtons("rbGraph2", "Graph:",
    choiceNames = list("product", "defect"),
    choiceValues = list("prod", "def"),
    inline = T
    ),
    radioButtons("rbDefect2", "Defect:",
    choiceNames = list("point", "rect"),
    choiceValues = list("point", "rect"),
    inline = T
    ),
    radioButtons("rbMain2", "Main:",
    choiceNames = list("T+B", "T", "B"),
    choiceValues = list("both", "top", "bot"),
    inline = T
    ),
    checkboxGroupInput("cbWeight2", "Weight:",
    choiceNames = list("int", "conf", "cat"),
    choiceValues = list("int", "conf", "cat"),
    inline = T
    ),
    fluidRow(
    column(6,
    numericInput("numIn2", "Opacity:", 1, min = 1, width = 100)
    ),
    column(6,
    textInput("txtIn2", "Max value:", "text here", width = 100)
    )
    )
    )
    ),
    column(10,
    plotOutput("prodPlot2")
    )
    )

    )

    # Server logic
    server <- function(input, output) {

    output$lineid <- renderText({paste("Line: ", as.character(tb_prod[tb_prod$id==input$prod,"lineid"]))})
    output$pdate <- renderText({paste("Date: ", as.character(tb_prod[tb_prod$id==input$prod,"pdate"]))})
    output$ptime <- renderText({paste("Time: ", as.character(tb_prod[tb_prod$id==input$prod,"ptime"]))})
    output$pfamily <- renderText({paste("Family: ", as.character(tb_prod[tb_prod$id==input$prod,"pfamily"]))})
    output$pac <- renderText({paste("Aspect: ", as.character(tb_prod[tb_prod$id==input$prod,"pac"]))})
    output$pcf <- renderText({paste("Conformity: ", as.character(tb_prod[tb_prod$id==input$prod,"pcf"]))})
    output$pl <- renderText({paste("Length: ", as.character(tb_prod[tb_prod$id==input$prod,"pl"]))})
    output$pw <- renderText({paste("Width: ", as.character(tb_prod[tb_prod$id==input$prod,"pw"]))})

    output$prodPlot1 <- output$prodPlot2 <- renderPlot({
    library(tidyverse)
    source<- paste0("C:/Digitalization/Shiny/ProductMaps/InputFiles/", input$prod, ".def")
    def <- read.csv(source)
    pl <- as.numeric(tb_prod[tb_prod$id==input$prod,"pl"])
    pw <- as.numeric(tb_prod[tb_prod$id==input$prod,"pw"])
    deftop <- def %>% filter(side == "S")
    defbot <- def %>% filter(side == "I")
    fullgrid <- genDefGrid(def, pl, pw,000)
    fullgridtop <- genDefGrid(deftop, pl, pw, 000)
    fullgridbot <- genDefGrid(defbot, pl, pw, 000)

    grid <- fullgrid %>% filter(z != 0)
    gridtop <- fullgridtop %>% filter(z != 0)
    gridbot <- fullgridbot %>% filter(z != 0)
    # product map preparation
    op <- 8
    step <- 100
    if (pl < 1000) { step <- 50 }
    if (pl < 300) { step <- 20 }
    # bi-side map without weigthing
    mprod <- ggplot(grid) +
    ggtitle("top+bot") +
    aes(x, y) +
    geom_point(shape=15, color = "blue", size = 2, alpha = (grid$z/op)) +
    scale_x_continuous(name= "length (m)", breaks=seq(0, max(fullgrid[,"x"]), step)) +
    scale_y_continuous(name= "width (mm)", breaks=seq(0, max(fullgrid[,"y"]), 100)) +
    expand_limits(x = 0, y = 0) +
    coord_cartesian(expand = FALSE) +
    theme(plot.title = element_text(size=10, hjust = 0.5), axis.title.x = element_text(size=10), axis.text.x= element_text(angle=30, hjust=1), axis.title.y = element_text(size=10), axis.text.y= element_text(angle=30, hjust=1))
    # top map without weigthing
    mprodt <- ggplot(gridtop) +
    ggtitle("top") +
    aes(x, y) +
    geom_point(shape=15, color = "blue", size = 2, alpha = (gridtop$z/op)) +
    scale_x_continuous(name= "length (m)", breaks=seq(0, max(fullgridtop[,"x"]), step)) +
    scale_y_continuous(name= "width (mm)", breaks=seq(0, max(fullgridtop[,"y"]), 100)) +
    expand_limits(x = 0, y = 0) +
    coord_cartesian(expand = FALSE) +
    theme(plot.title = element_text(size=10, hjust = 0.5), axis.title.x = element_text(size=10), axis.text.x= element_text(angle=30, hjust=1), axis.title.y = element_text(size=10), axis.text.y= element_text(angle=30, hjust=1))
    # top map without weigthing
    mprodb <- ggplot(gridbot) +
    ggtitle("bot") +
    aes(x, y) +
    geom_point(shape=15, color = "blue", size = 2, alpha = (gridbot$z/op)) +
    scale_x_continuous(name= "length (m)", breaks=seq(0, max(fullgridbot[,"x"]), step)) +
    scale_y_continuous(name= "width (mm)", breaks=seq(0, max(fullgridbot[,"y"]), 100)) +
    expand_limits(x = 0, y = 0) +
    coord_cartesian(expand = FALSE) +
    theme(plot.title = element_text(size=10, hjust = 0.5), axis.title.x = element_text(size=10), axis.text.x= element_text(angle=30, hjust=1), axis.title.y = element_text(size=10), axis.text.y= element_text(angle=30, hjust=1))
    grid.arrange(mprod, mprodt, mprodb, ncol = 2, layout_matrix = cbind(c(1,1), c(2,3)), widths=c(2,1))
    })
    }

    # Complete app with UI and server components
    shinyApp(ui, server)
    Images attachées Images attachées  

Discussions similaires

  1. demande d'aide sur samba
    Par marcoss dans le forum Développement
    Réponses: 5
    Dernier message: 04/12/2003, 19h38
  2. [CR] besoin d'aide sur les formules
    Par GuillaumeDSA dans le forum Formules
    Réponses: 4
    Dernier message: 10/07/2003, 12h19
  3. Réponses: 2
    Dernier message: 27/02/2003, 01h33
  4. [Kylix] Aide sur BitBlt
    Par mic006 dans le forum EDI
    Réponses: 1
    Dernier message: 10/12/2002, 22h54
  5. Aide sur une fenetre
    Par Ray-j dans le forum Autres éditeurs
    Réponses: 4
    Dernier message: 29/11/2002, 08h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo