addDataDF {psychReport} | R Documentation |
addDataDF
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
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
# 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)
[Package psychReport version 3.0.2 Index]