ezResample {ez} | R Documentation |
Resample data from a factorial experiment
Description
This function resamples data (useful when bootstrapping and used by ezBoot
).
Usage
ezResample(
data
, wid
, within = NULL
, between = NULL
, resample_within = FALSE
, resample_between = TRUE
, check_args = TRUE
)
Arguments
data |
Data frame containing the data to be analyzed. |
wid |
.() object specifying the column in |
within |
Optional .() object specifying one or more columns in |
between |
Optional .() object specifying one or more columns in |
resample_within |
Logical. If TRUE, and if there are multiple observations per subject within each cell of the design specified by the factorial combination of variables supplied to |
resample_between |
Logical. If TRUE (default), levels of |
check_args |
Users should leave this as its default (TRUE) value. This argument is intended for internal use only. |
Value
A data frame consisting of the resampled data
Author(s)
Michael A. Lawrence mike.lwrnc@gmail.com
Visit the ez
development site at http://github.com/mike-lawrence/ez
for the bug/issue tracker and the link to the mailing list.
See Also
Examples
library(plyr)
#Read in the ANT data (see ?ANT).
data(ANT)
head(ANT)
ezPrecis(ANT)
#Bootstrap the within-cell variances
var_boots = ldply(
.data = 1:1e1 #1e3 or higher should be used for publication
, .fun = function(x){
this_resample = ezResample(
data = ANT[ANT$error==0,]
, wid = .(subnum)
, within = .(cue,flank)
, between = .(group)
)
cell_vars = ddply(
.data = idata.frame(this_resample)
, .variables = .(subnum,cue,flank,group)
, .fun = function(x){
to_return = data.frame(
value = var(x$rt)
)
return(to_return)
}
)
mean_cell_vars = ddply(
.data = idata.frame(cell_vars)
, .variables = .(cue,flank,group)
, .fun = function(x){
to_return = data.frame(
value = mean(x$value)
)
return(to_return)
}
)
mean_cell_vars$iteration = x
return(mean_cell_vars)
}
, .progress = 'time'
)