[R] Omitting members of a sequence
Jim Lemon
jim at bitwrit.com.au
Sat Feb 20 10:45:05 CET 2010
On 02/20/2010 08:33 AM, Stuart Luppescu wrote:
> Hello, this is just a point of curiosity with me. I want a sequence of
> numbers from 64 to 70, omitting the 2nd and 4th numbers. I can do it
> these ways:
>
>> seq(64, 70)[-c(2, 4)]
> [1] 64 66 68 69 70
>
>> foo<- 64:70
>> foo[-c(2, 4)]
> [1] 64 66 68 69 70
>
> But how come this doesn't work?
>> 64:70[-c(2, 4)]
> [1] 64 65 66 67 68 69 70
>
> Just wondering.
Ah, but it does work!
(64:70)[-c(2,4)]
[1] 64 66 68 69 70
Jim
More information about the R-help
mailing list