Pete Brecknock
2012-Feb-14 18:36 UTC
[R] finding the subscript of a vector fulfiiling a given condition
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.
Reasonably Related Threads
- lattice subscripts with both condition and group
- handling of zero and negative indices in src/main/subscript.c:mat2indsub() (PR#7824)
- problem of subscript value from vector and list
- A "subscript out of bonds" and "write.table" problem on manipulating a large size dataset
- How to get % and subscript in plotmath