experiment: Create an experiment.

Description Usage Arguments Details Value Examples

Description

In betr, an experiment consists of one or more stages, as well as global options defined when the experiment is created.

Usage

1

Arguments

auth

TRUE, FALSE, a character vector of patterns, or a function. See Details

port

what port to listen on

autostart

logical. Start the experiment automatically when N participants have joined?

allow_latecomers

logical. Allow participants to join after the experiment has started?

N

a numeric giving how many participants are required

server

a class name (quoted or unquoted) of a betr::Server subclass, or an instance object. Typical: "RookServer"

name

the character name of the experiment, used in creating folders.

client_refresh

numeric. How often should waiting clients refresh their pages?

clients_in_url

logical. If TRUE, client names can be specified in the URL as e.g. experiment/client_name. Useful for testing, should be turned off in production!

seats_file

path of the file where seat information is stored. See identify_seats for details. Note: to suppress warnings about a missing file, use seats_file=NULL.

on_ready

a user-defined function, to be called when ready is called.

randomize_ids

if TRUE, subject IDs will be randomized from 1 to N. If FALSE subject IDs will be allocated first-come first-served.

record

records experiment commands to disk. Turning this off will save disk space and not clutter your working directory, but will prevent experiment replay.

seed

a seed to set whenever ready is called. You should ensure you set this to a different value in every session.

Details

An experiment is typically created in a source file, which also adds one or more stages to it using add_stage. When you run the experiment, you source this file. Call ready(experiment) when you want subjects to be able to connect to the server. They will see a waiting page which refreshes regularly. To see your experiment's status, call info(experiment) or simply type experiment on the command line. When you want the experiment to start, call start(experiment).

To keep your experiments replay-safe, use on_ready to initialize your data.

The parameter auth determines how you authorize clients. TRUE (the default) allows any client to join the experiment. If auth is a character vector, it is treated as a list of patterns in shell-glob style, e.g. "192.168.*.*" (see glob2rx for details). If the client's IP address matches any pattern, the client will be accepted. IF auth is a function, it will be called like auth(ip, params, cookies) where ip is the remote IP address and params and cookies are lists of HTTP parameters and cookies respectively. The client will be authorized if the function returns TRUE.

Value

an object of class Experiment.

Examples

1
2
3
expt <- experiment(name='testing', port=12345, N=4)
add_stage(expt, function(...)"<html><body>Hello world!</body><html>")
ready(expt)

hughjonesd/betr documentation built on May 17, 2019, 9:11 p.m.