Hi, I have a matrix given by: >mat trace iterations [1,] 0.8959863 1 [2,] 0.8951168 2 [3,] 0.8971445 3 [4,] 0.8962497 4 [5,] 0.8963061 5 [6,] 0.8973174 6 [7,] 0.8986438 7 [8,] 0.8964609 8 [9,] 0.8975849 9 [10,] 0.8965599 10
I want to use the code below: It keeps the first observation but compares all the rest with the earlier one and drops the one that is larger and it continues until all the rows are done. while(nrow(mat) > 1){ high <- diff(mat[, 'trace']) > 0 if (!any(high)) break # done # find which one to delete delete <- which.max(high) + 1L mat <- mat[-delete,, drop=FALSE] } The error I get is " Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to binary operator" How do I fix it? Laz [[alternative HTML version deleted]] ______________________________________________ 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.