Sorry it was my mistake. I tried to do like this rm.outliers = function(model,xsys) {
rst = rstudent(model) outliers<<-vector("numeric",731) xsys<<-xsys for(i in 1:length(rst)) { if(rst[i]<=3 & rst[i]>=-3) #condition for identifying outlier { print("this is not outlier") print(i) } else { print("this is an outlier") print(i) outliers[i]<<-c(i) print(outliers) } i<-i+1 } #xsys<-xsys[-outliers,] print(" printing rows") nrow(xsys) #return(xsys) } rm.outliers(fitted.modely1.temp.l,xsys) I am returning xsys(my dataset) but it wont affect in globel environment. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.