I am using R and I created based on a vector x, a grid (named: plain) - where zero is included. This gives me a 9x2 ``matrix''.
> x_t = cbind(c(1),c(2)); > x = t(x_t); > plain = expand.grid (sort (unique (c (0, x))), sort (unique (c (0, x)))); My aim is to focus on column 1 and take i.e the first entry (then the second, the third entry etc through a loop) of the unique (c (0, x)) vector (==0) [rows 1, 4 and 7] and find the maximum value (entry) in the second column of the matrix that satisfies a condition. Let say that the condition is satisfied when at column 2 the value is 2. That is I want row 7 to be selected Then I want to create a column vector b (9x1) that has zero everywhere apart from row 7. Can anybody help me with this? Thank you in advance. [[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.