[R] which function

From: arnaud Gaboury <arnaud.gaboury_at_gmail.com>
Date: Wed, 02 Jun 2010 09:41:21 +0200


Dear group,

Here is a list of elements :

l <-
c("100415", "100416", "100419", "100420", "100421", "100422",

"100423", "100426", "100427", "100428", "100429", "100430", "100503", 
"100504", "100505", "100506", "100507", "100510", "100511", "100512", 
"100513", "100514", "100517", "100518", "100519", "100520", "100521", 
"100524", "100525", "100526", "100527", "100528", "100531")


> l[3:4]

[1] "100419" "100420" #result is fine

> l[(which(100420==l))-1:which(100420==l)]
[1] "100419" "100416" "100415" #can't understand why I do not have same result than the above line

Thank You for help



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 Wed 02 Jun 2010 - 07:44:57 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 Wed 02 Jun 2010 - 09:10:25 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