0

I want to perform some actions like writing in a dataframe post i close the modaldialogue. Consider below example.

obs8<-observe({   req(input$Continue)   if(input$password3 > 0  & input$password4 > 0 & (input$password3==input$password4)==TRUE & (is.validpw(input$password3))==TRUE & (is.validpw(input$password4))==TRUE){
     showModal(modalDialog(
       title=tags$h4(tags$strong("Password Changed Successfully")),
       easyClose=FALSE,
       footer=modalButton("Close")
     ))

I am trying to execute below code post the if condition is true and modal is displayed but no luck.

PASSWORD$Passord <- as.character(PASSWORD$Passord)
PASSWORD$Passord[PASSWORD$Passord==pwd] <- input$password3 
PASSWORD$Passord <- as.factor(PASSWORD$Passord) 
write.csv(PASSWORD,"<PATH>",row.names=FALSE)
Florian
  • 24,425
  • 4
  • 49
  • 80
Kaverisonu
  • 101
  • 2
  • 10
  • Please consider adding a reproducible example to your question, that makes it much easier to help. For some tips on how to do that, see [here](https://stackoverflow.com/questions/48343080/how-to-convert-a-shiny-app-consisting-of-multiple-files-into-an-easily-shareable). – Florian Feb 07 '18 at 11:31

1 Answers1

0

I rewrote it as pure Shiny without all the password stuff and it works fine:

ui <- fluidPage(

  # Application title
  titlePanel("Old Faithful Geyser Data"),

  # Sidebar with a slider input for number of bins 
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),

    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot")
    )
  )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

  output$distPlot <- renderPlot({
    # generate bins based on input$bins from ui.R
    x    <- faithful[, 2] 
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })

  obs8<-observe({
    req(input$bins)   
    if(input$bins > 40){

      showModal(modalDialog(
        title=tags$h4(tags$strong("Password Changed Successfully")),
        easyClose=FALSE,
        footer=modalButton("Close")
      ))

      write.csv("1, 2, 1, 2", "<PATH>", row.names = FALSE)
    }
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

There's something wrong with the other stuff you're doing, but I can't tell what it is without a reproducible example

Chris Beeley
  • 591
  • 6
  • 22
  • Thanks Chris!!If write.csv is working for you,then it should work for me as well,i tried above method,but the file was not written.I might have to check again then!! – Kaverisonu Feb 09 '18 at 07:17