if (FALSE) {
analyse <- function(condition, dat, fixed_objects) {
# require packages/define functions if needed, or better yet index with the :: operator
require(stats)
mygreatfunction <- function(x) print('Do some stuff')
#wrap computational statistics in try() statements to control estimation problems
welch <- t.test(DV ~ group, dat)
ind <- stats::t.test(DV ~ group, dat, var.equal=TRUE)
# In this function the p values for the t-tests are returned,
# and make sure to name each element, for future reference
ret <- c(welch = welch$p.value,
independent = ind$p.value)
return(ret)
}
# A more modularized example approach
analysis_welch <- function(condition, dat, fixed_objects) {
welch <- t.test(DV ~ group, dat)
ret <- c(p=welch$p.value)
ret
}
analysis_ind <- function(condition, dat, fixed_objects) {
ind <- t.test(DV ~ group, dat, var.equal=TRUE)
ret <- c(p=ind$p.value)
ret
}
# pass functions as a named list
# runSimulation(..., analyse=list(welch=analyse_welch, independent=analysis_ind))
}
Run the code above in your browser using DataLab