[R] "Delete row" takes ages. alternative?!

David Winsemius dwinsemius at comcast.net
Sun Jul 10 06:56:10 CEST 2011


On Jul 9, 2011, at 11:42 PM, David Winsemius wrote:

>
> On Jul 9, 2011, at 9:37 PM, Rolf Turner wrote:
>
>> On 10/07/11 12:12, David Winsemius wrote:
>>
>> <SNIP>
>>
>> Uhhh, you meant
>>> drpidx <- -c(5,10, i)
>>> x <- x[-drpidx, ]
>>>
>>
> Yes, I certainly did. Thanks for the correction.

A little bird has tweeted that I might NOT have wanted to accept that"

 > i <- 5
 > del.idx <- c(4,7,i)  # Notice no minus sign.

 > (1:10)[-del.idx]
[1]  1  2  3  6  8  9 10

Double negation turns the result positive:
 > del.idx <- -c(4,7,i)
 > (1:10)[-del.idx]  # minus a minus
[1] 4 7 5
>
>>   cheers,
>>
>>       Rolf Turner
-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list