[R] Find the max entry in column 2 - that satisfies a condition given a fixed entry in column 1

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Fri Jun 21 02:08:32 CEST 2019


"Can anybody help me with this?"

Probably not. Your explanation is as clear as mud -- to me anyway. Showing
us the actual data or code of a simple example, what you want to do and
what you have tried, and what you would like to get would likely help
(assuming it's not just me being dense, always a distinct possibility!).

And please *post in **plain text** not html* to avoid opaque text
formatting in this plain text list.

Cheers,
Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Jun 20, 2019 at 4:50 PM Vangelis Litos <Redondo5_447 using hotmail.com>
wrote:

> 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 using 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list