Re: [R] Problem with error handling inside a function

2008-10-25 Thread Gabor Grothendieck
Try this: evaluate.all <- function(response, DF = iris) { DF <- cbind(response = DF[[response]], DF) L <- list( # some linear models: B1 = try(lm(response ~ Sepal.Length, DF)), L2 = try(lm(response ~ Sepal.Width, DF)), # s

[R] Problem with error handling inside a function

2008-10-25 Thread Dr. Christoph Scherber
Dear R users, I have written a function that runs several statistical models and extracts the AIC values from them. As a (nonsense) example, I use the iris dataset: # data(iris) attach(iris) evaluate.all=function(response,...){ response=get(response) #retrieves the response variab