I have the shiny app below in which initially lands the user to Bet1
tabPanel. Then the user chooses one of the three actionbuttons below and I want the answer (label of the actionButton
) to be recorded in a csv file created inside the working directory.Then the user is moved automatically to Bet2
tabPanel and does the same. The answers should be recorded in a way that the Bet1
,Bet2
are the column names and the answers (actionButtons
labels) as rows like:
Bet1 Bet2
1 Je choisis option A Je choisis option B
#app
library(shiny)
library(shinyjs)
outputDir <- "responses"
saveData <- function(mydata, namedata){
fileName=paste0(paste(namedata,as.integer(Sys.time()),sep="_"),".csv")
filePath <- file.path(tempdir(), fileName)
write.csv(mydata, filePath, row.names = FALSE, quote = TRUE)
}
ui <- fluidPage(
id="main",
title="Risk and ambiguity",
useShinyjs(),
navlistPanel(id="main",
tabPanel("Bet1",
fluidRow(column(12, align='center',
hr("Choisissez urne A, urne B ou un sac avec A et B:"))),
####
fluidRow(wellPanel(
splitLayout(cellWidths = c("33%", "33%", "33%"),
column(12,align="center",actionButton("action1", label = "Je choisis option A")),
column(12,align="center",actionButton("action2", label = "Je choisis le sac avec A et B")),
column(12,align="center",actionButton("action3", label = "Je choisis option B"))) ))),
tabPanel("Bet2",
fluidRow(column(12, align='center',
hr("Choisissez urne A, urne B ou un sac avec A et B:"))),
####
fluidRow(wellPanel(
splitLayout(cellWidths = c("33%", "33%", "33%"),
column(12,align="center",actionButton("action1", label = "Je choisis option A")),
column(12,align="center",actionButton("action2", label = "Je choisis le sac avec A et B")),
column(12,align="center",actionButton("action3", label = "Je choisis option B"))) )))
))
#################
server <- function(input, output){
}
shinyApp(ui = ui, server = server)