Hello everyone, I have a problem using a for-loop to go through a matrix. I want to remove all rows with a sum of 0. What I do is basically:
for(i in 1:length(data)) { if(sum(add(data[i,]) == 0) { data <- data[-i,] } } I get a error message: "Error in `[.data.frame`(data, i) : undefined columns selected", because the length is reduced when removing in the if-clause. How do I make this? Best wishes, Markus ______________________________________________ R-help@r-project.org mailing list 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.