myanalyse <- function(condition, dat, parameters = NULL){
# 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 <- try(t.test(DV ~ group, dat), silent=TRUE)
ind <- try(stats::t.test(DV ~ group, dat, var.equal=TRUE), silent=TRUE)
# check if error, and if so stop and return an 'error'. This will re-draw the data
if(is(welch, 'try-error')) stop('Welch error message')
if(is(ind, 'try-error')) stop('Independent t-test error message')
# 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)
}Run the code above in your browser using DataLab