8  CreateSimulatePrepare

Here you can see the full process of creating a protocol with jsPsychMaker, simulating participants with jsPsychMonkeys and preparing the data with jsPsychHelpeR:

8.1 Create protocol

Create a protocol with jsPsychMaker::create_protocol():

# 1) Install jsPsychMaker
if (!require('remotes')) install.packages('remotes'); remotes::install_github("gorkang/jsPsychMaker")

# 2) Check available tasks
jsPsychMaker::list_available_tasks()$tasks

# 3) Create protocol
jsPsychMaker::create_protocol(canonical_tasks = c("AIM", "EAR", "IRI"),
                              folder_output = "~/Downloads/protocol999", 
                              launch_browser = FALSE)

You can now edit the configuration file (~/Downloads/protocol999/config.js) to adjust the project’s parameters.

8.2 Simulate participants

Simulate participants with {jsPsychMonkeys}. Make sure your system has a functioning docker installation, see jsPsychMonkey’s setup.

If you are on Windows, make sure Docker Desktop is open and running before releasing the monkeys.

# 1) Install jsPsychMonkeys
if (!require('remotes')) utils::install.packages('remotes'); remotes::install_github('gorkang/jsPsychMonkeys')

# 2) Run monkeys
  # Go to _targets.R: Change parameter `local_folder_tasks` to your folder_output above. For example:  
  # - On Ubuntu, `local_folder_tasks = "~/Downloads/protocol999"`
  # - On Windows, `local_folder_tasks = "C:/Users/myusername/Downloads/protocol999"`

jsPsychMonkeys::release_the_monkeys(uid = 1:10, 
                                    local_folder_tasks = "~/Downloads/protocol999/")

The monkeys responses csv’s should be initially downloaded in your Downloads folder, and automatically moved to a .data/ folder inside the protocol folder. For example, ~/Downloads/protocol999/.data

8.3 Prepare data

Create a data preparation project with jsPsychHelpeR::run_initial_setup():

# 1) Install
if (!require('remotes')) install.packages('remotes'); remotes::install_github("gorkang/jsPsychHelpeR")

# 2) Create project
jsPsychHelpeR::run_initial_setup(pid = "999", data_location = "~/Downloads/protocol999/.data", dont_ask = TRUE)

# 3) Restore all the necessary packages using {renv}
renv::restore(prompt = FALSE)

# 4) Run data preparation
targets::tar_make()

If you don’t give a value to the folder parameter in jsPsychHelpeR::run_initial_setup(), the new project will be created in ~/Downloads/jsPsychHelpeRtest/. After step 4), the prepared data can be found in the outputs/data folder of the new project, reports in outputs/reports, etc.