Skip to content
Back to formatted view

Raw Message

Message-ID: <1329244618567-4388042.post@n4.nabble.com>
Date: 2012-02-14T18:36:58Z
From: Pete Brecknock
Subject: finding the subscript of a vector fulfiiling a given condition
In-Reply-To: <1329242062875-4387870.post@n4.nabble.com>

galemago wrote
> 
> Dear Forum,
> 
> I just recently started to work with R, I?d like to know if there is a way
> to give instructions/do operations related to values with different
> subscripts within a vector.
> Let?s assume I have a vector like this:
> A="368    369    370    371   393    394    395"
> If I call "j" the subscripts of the vector I?d like to find the j value
> such that A(j+1)-A(j) is the maximum.
> This would tell me at which position of the vector I have the biggest gap.
> (the fifth in the example above)
> My problem is that I don?t find a way to define the vector subscripts as a
> variable, that I believe is what I need to solve this problem. Is that
> possible? 
> Thanks a lot, hope to come back often in this forum,
> G.
> 

How about ...

A <- c(368,369,370,371,393,394,395)

which.max(diff(A))

HTH

Pete


--
View this message in context: http://r.789695.n4.nabble.com/finding-the-subscript-of-a-vector-fulfiiling-a-given-condition-tp4387870p4388042.html
Sent from the R help mailing list archive at Nabble.com.