18 January 2017
knitr::opts_chunk$set(echo = TRUE)
This app runs the Balloon Analogue Risk Task (BART), a measure developed by @lejuez2002evaluation as a behavioral measure of risk taking. It has been extended to include a competitive version in which regular feedback is given.
There are three versions available:
ShinyBART_app.R, is an implementation in pure shiny. Since every pump must be handled by the server, it can lead to some lag. It might be better suited for experiments in a lab.
The second version,
Finaly, the last version is
ShinyBART_app_JS_comp.R, which is a two-player version of the BART. After each block both players receive feedback about their and their opponents performance. It can either be used in "direct" mode, where each player needs the ID of an opponent who is online to connect, or a "lobby" version in which a player will be kept waiting untill any second player logs in.
Here are some examples of ShinyBART you can play right now! (You will need a competitor, or a second browser window for the competitive version.)
|Basic ShinyBART||https://econpsychbasel.shinyapps.io/ShinyBART/||GitHub Source Code|
|1-Player ShinyBART||https://econpsychbasel.shinyapps.io/single_shinybart/||GitHub Source Code|
|Multyplayer ShinyBART||https://econpsychbasel.shinyapps.io/competitive_shinybart/||GitHub Source Code|
Using the Application
The game is stored in the
BalloonGame.js file in the same directory. Every version of the app is separated into several sections:
|0: Load Libraries||Load all libraries necessary to run the application. Be sure to include
|A: Setup the game||Define game parameters (A1), define how data will be saved (A2)|
|B: Overall Layout||Define the app title and add custom CSS tags. The JS versions also call the .js file here.|
|C: Reactive Values||Define the reactive values which store user inputs throughout the game.
|D: Page Layouts||The content and layout of distinct pages (e.g.; welcome page, instructions page, game page)|
|E: Game Display / Plotting Function||The main game display and example game displays (E1). Not needed in the JS versions.|
|F: Event (button) actions||Define the result of buttons such as page navigation (F1) and event tracking such as saving a balloon (F2)|
|G: Save data||Define how data is saved and exported|
Uploading data to Dropbox
In order to upload data to Dropbox, you must include a file called
droptoken.rds containing your dropbox authentication token. This file must be in the same folder as the main application file
ShinyBanditMulti_app.R. You can create this file by running the following:
install.packages("rdrop2") # install rdrop2 packagre droptoken <- rdrop2::drop_auth() # Will open a browser and ask you to login saveRDS(droptoken, file = "droptoken.rds") # Save token as droptoken.rds
You can specify the folder to save your data in with the
outputDir object (This object will later on be passed to the
rdrop2::drop_upload() function when it is time to actually save the data). For example,
outputDir <- "ShinyApp/data" will save the data to a data folder contained in a ShinyApp folder.
Receiving the data via Email is not yet implemented.