Re: [R] Position in a vector of the last value > n

From: jim holtman <jholtman_at_gmail.com>
Date: Thu, 10 Jul 2008 22:21:18 -0400

Here is one way:

> v <- c(20, 134, 45, 20, 24, 500, 20, 20, 20)
> tail(v[v>20],1)
[1] 500

On Thu, Jul 10, 2008 at 8:41 AM, Thaden, John J <ThadenJohnJ_at_uams.edu> wrote:
> This shouldn't be hard, but it's just not
> coming to me:
> Given a vector, e.g.,
> v <- c(20, 134, 45, 20, 24, 500, 20, 20, 20)
> how can I get the index of the last value in
> the vector having a value greater than n, in
> this case, greater than 20? I'm looking for
> an efficient function I can use on very large
> matrices, as the FUN argument in the apply()
> command.
>
> Confidentiality Notice: This e-mail message, including a...{{dropped:8}}
>
> ______________________________________________
> R-help_at_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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
R-help_at_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.
Received on Fri 11 Jul 2008 - 02:26:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Jul 2008 - 04:32:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive