[R] removing outlier function / dataset update

2011-01-26 Thread kirtau
Hi, I have a few lines of code that will remove outliers for a regression test based on the studentized residuals being above or below 3, -3. I have to do this multiple times and have attempted to create a function to lessen the amount of copying, pasting and replacing. I run into trouble with

Re: [R] removing outlier function / dataset update

2011-01-26 Thread Ista Zahn
Hi, x and y are being picked up from your global environment, not from the x and y in dataset. Here is a version that seems to work: rm.outliers = function(dataset,var1, var2) { dataset$varpredicted = predict(lm(as.formula(paste(var1, var2, sep= ~ )), data=dataset)) dataset$varstdres =

Re: [R] removing outlier function / dataset update

2011-01-26 Thread kirtau
First off, thank you for the help with the global environment. I have however attempted to run the code and am now presented with a new error which is Error in formula.default(eval(parse(text = x)[[1L]])) : invalid formula and am not sure what to make of it. I have tried a few different work