addDataDF: addDataDF

Description Usage Arguments Value Examples

View source: R/psychReportData.R

Description

Add simulated ex-gaussian reaction-time (RT) data and binary error (Error = 1, Correct = 0) data to an R DataFrame. This function can be used to create simulated data sets.

Usage

1
addDataDF(dat, RT = NULL, Error = NULL)

Arguments

dat

DataFrame (see createDF)

RT

RT parameters (see rtDist)

Error

Error parameters (see errDist)

Value

DataFrame with RT (ms) and Error (bool) columns

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Example 1: default dataframe
dat <- createDF()
dat <- addDataDF(dat)
hist(dat$RT, 100)
table(dat$Error)

# Example 2: defined overall RT parameters
dat <- createDF(nVP = 50, nTrl = 50, design = list("Comp" = c("comp", "incomp")))
dat <- addDataDF(dat, RT = c(500, 150, 100))
boxplot(dat$RT ~ dat$Comp)
table(dat$Comp, dat$Error)

# Example 3: defined RT + Error parameters across conditions
dat <- createDF(nVP = 50, nTrl = 50, design = list("Comp" = c("comp", "incomp")))
dat <- addDataDF(dat,
  RT = list(
    "Comp comp" = c(500, 80, 100),
    "Comp incomp" = c(550, 80, 140)
  ),
  Error = list(
    "Comp comp" = 5,
    "Comp incomp" = 10
  )
)
boxplot(dat$RT ~ dat$Comp)
table(dat$Comp, dat$Error)

# Example 4:
# create dataframe with defined RT + Error parameters across different conditions
dat <- createDF(nVP = 50, nTrl = 50, design = list("Comp" = c("comp", "incomp", "neutral")))
dat <- addDataDF(dat,
  RT = list(
    "Comp comp" = c(500, 150, 100),
    "Comp neutral" = c(550, 150, 100),
    "Comp incomp" = c(600, 150, 100)
  ),
  Error = list(
    "Comp comp" = 5,
    "Comp neutral" = 10,
    "Comp incomp" = 15
  )
)
boxplot(dat$RT ~ dat$Comp)
table(dat$Comp, dat$Error)

# Example 5:
# create dataframe with defined RT + Error parameters across different conditions
dat <- createDF(
  nVP = 50, nTrl = 50,
  design = list(
    "Hand" = c("left_a", "right_a"),
    "Side" = c("left_a", "right_a")
  )
)
dat <- addDataDF(dat,
  RT = list(
    "Hand:Side left_a:left_a" = c(400, 150, 100),
    "Hand:Side left_a:right_a" = c(500, 150, 100),
    "Hand:Side right_a:left_a" = c(500, 150, 100),
    "Hand:Side right_a:right_a" = c(400, 150, 100)
  ),
  Error = list(
    "Hand:Side left_a:left_a" = c(5, 4, 2, 2, 1),
    "Hand:Side left_a:right_a" = c(15, 4, 2, 2, 1),
    "Hand:Side right_a:left_a" = c(15, 7, 4, 2, 1),
    "Hand:Side right_a:right_a" = c(5, 8, 5, 3, 1)
  )
)

boxplot(dat$RT ~ dat$Hand + dat$Side)
table(dat$Error, dat$Hand, dat$Side)

psychReport documentation built on May 6, 2021, 5:05 p.m.