participants: Print the participant section for a manuscript from a...

Description Usage Arguments Details Value References Examples

View source: R/participants.R

Description

Print the participant section for a manuscript from a data.frame

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
participants(
  data,
  id,
  age,
  gender,
  excl,
  date = NULL,
  recruitedfrom = NULL,
  collectedat = NULL,
  approvedby = NULL,
  compensation = NULL,
  gender.label = NULL,
  date.format = NULL,
  currency = "US dollar",
  more = NULL,
  file = NULL
)

Arguments

data

data object for which the demographics should be printed.

id

a string, name of the column in data that holds subject identifiers, defaults to "id".

age

a string, name of the column in data that holds the age, defaults to "age".

gender

a string, name of the column in data that holds the gender, defaults to "gender". If gender is numeric you should supply the argument gender.label.

excl

a string or a number. A number specifies how many participants have been excluded from data; and the data must be after list-wise exclusion. Alternatively, a string specifies the name of the variable in data holding reasons for excluding participants with NA or "" values for including participants. In this case data must contain the participants to be excluded. Exclusion will be performed in the function before computing demographics.

date

(optional) a string, either the data collection period (e.g., "April to May 2019"), or the name of the variable in data holding time stamps. Ideally, this variable is in datetime format (with as.POSIXlt), if it is a character/string the format will be guessed, or can be specified by date.format.

recruitedfrom

(optional) a string, where were participants recruited? E.g., "Amazon Mechanical Turk" or "Harvard's subject pool".

collectedat

(optional) string, where was the data collected? E.g. "online" or Stanford University".

approvedby

(optional) string, which ethics board approved the study? E.g., "the Oxford University's ethics comittee"

compensation

(optional) a string, either "course credit", or the name of the variable in data holding how much participants received. Consider specifying the payment currency, see the argument currency.

gender.label

(optional) if the values of the gender variable in data are numeric, specify which number represents which gender, e.g. c(1 = "female", 2 = "male", 3 = "no answer").

date.format

(optional) if date in data has character format (and not POSIXct, which is the R date format) it may be ambiguous if "02-10-2020" means 02. Oct. or 10. Feb. In this case an error is thrown and date.format needs to be supplied. If "02-10-2020" means 02. Oct. use date.format = "%d%m%Y", if "02-10-2020" means 10. Feb. use date.format = "%m%d%Y".

currency

(optional) string, only if the argument compensation refers to a monetary values, specify the currency, default is currency = "US dollar".

more

(optional) list, specifying additional variables to be summarized. See details.

file

(optional) string, output file location, can be *.tex or *.txt.

Details

The argument more works as follows: You want to print "Mean study duration was ... minutes". Your data contains a variable dur_min. Specify this: more = list("study duration" = c("time_min", "minutes")), the name "study duration" is the name to be printed, "time_min" is the column name in your data, and "minute" determines the unit (in singular).

Value

A string with the participant description.

References

Sutton, R. S., & Barto, A. G. (1998). ReINforcement learnINg: An INtroduction. Cambridge, MA: MIT Press

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
mydata <- data.frame(
    id =   1:3,
    date = c("01102010-10:30", "02102010-10:30", "03102010-10:30"),
    payed = c(10,7,1.56),
    age =   c(20,22,21),
    fem =   c("m","f","m"),
    dur_min = c(22, 25, 30),
    income = c(1200, 1500, 2400))

# Print minimal demographics
participants(mydata, id = "id", age = "age", gender = "fem", excl = 0)

# Result:
# In total three participants completed the study (zero were excluded),
# 2 males and 1 female (67% and 33%, respectively), mean age 21 years
# (med = 21, sd = 1, range 20-22 years). 
# Note, this is too little information according to APA.

# Add the date
participants(mydata, id = "id", age = "age", gender = "fem", excl = 0,
             date = "date",
             date.format = "%d%m%Y") # since date is not un-ambiguous

# Add where the data was collected
participants(mydata, id = "id", age = "age", gender = "fem", excl = 0, 
             date = "date", date.format = "%d%m%Y", 
             collectedat = "the University of Basel") # local
participants(mydata, id = "id", age = "age", gender = "fem", excl = 0,
             date = "date", date.format = "%d%m%Y", collectedat = "online")

# Add further variables: income
participants(mydata, id = "id", age = "age", gender = "fem", excl = 0,
            date = "date", date.format = "%d%m%Y", collectedat = "online",
            more = list("income" = c("income", "CHF")))

# Exclude one participant
mydata$exclusion <- c(NA, NA, 'failing attention checks') 
participants(mydata, id = "id", age = "age", gender = "fem", excl = "exclusion")


# Save result to file
participants(mydata, id = "id", age = "age", gender = "fem", excl = 0, file = "participants.txt")

JanaJarecki/cognitiveutils documentation built on Sept. 9, 2020, 9:11 a.m.