PsyCloud

Quickstart: R

Build a working study in R in a few minutes. For the full API, see the R SDK reference.

  1. Install psycloudr
    # install.packages("remotes")
    remotes::install_github("bbuchsbaum/psycloud", subdir = "packages/psycloudr")
  2. Write a study

    Save this as hello-rt.R. It builds a minimal reaction-time task — a colored circle appears after a fixation cross, and the participant presses any key.

    hello-rt.R
    library(psycloudr)
     
    bundle <- experiment(id = "hello.rt", name = "Hello, psycloudr") |>
      instructions(markdown(
        "# Reaction Time\n\nPress any key when the circle appears."
      )) |>
      phase("main", label = "Trials") |>
        factors(color = c("tomato", "steelblue")) |>
        cross() |>
        repeat_rows(3) |>
        shuffle(seed = seed_per_participant("hello-rt")) |>
      screen("trial") |>
        present(fixation_cross(x = "center", y = "center", size = 40), 700) |>
        ask(circle(x = "center", y = "center", radius = 60, fill = trial$color), anykey()) |>
        record(color) |>
      end_screen(markdown("# Done\n\nThanks!")) |>
      bundle(with_auto_ids = TRUE)
  3. Inspect and write the bundle
    psycloud(bundle)                                   # inline preview in RStudio
    write_bundle(bundle, dir = "hello_rt_bundle", overwrite = TRUE)
  4. Run or edit it

    Validate or compile the bundle with the CLI, or open hello_rt_bundle/ in Studio via New Study → Import bundle to keep editing visually.

Dynamic values

trial$color binds each trial's value into the circle's fill. The expression DSL covers conditionals (case_when, expr_if), derived columns, and response-based logic.

Next