[R] which function

Ivan Calandra ivan.calandra at uni-hamburg.de
Wed Jun 2 10:21:27 CEST 2010


Hi,

Try with more parentheses:
 > l[((which(100420==l))-1):which(100420==l)]
[1] "100419" "100420"

It was interpreted as 4-(1:4)=3 2 1 0

Ivan

Le 6/2/2010 09:41, arnaud Gaboury a écrit :
> 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.
>
>    

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra at uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php



More information about the R-help mailing list