[prev in list] [next in list] [prev in thread] [next in thread] 

List:       r-help
Subject:    Re: [R] Increment element of vector and efficiency
From:       "Roger D. Peng" <rpeng () jhsph ! edu>
Date:       2003-11-20 13:56:38
[Download RAW message or body]

I think that's about as efficient as you can get.  I'm not sure of the 
underlying details.  There was some discussion recently of having the 
equivalent of a "+=" operator but currently R has no such thing.

-roger

Pascal A. Niklaus wrote:
> Hi all,
> 
> Thanks for the incredibly quick help with the "%in%"...
> 
> There's a second question, though: I'd like to increment an element of a 
> vector if a certain event occurs, e.g.
> 
>    count[event] <- count[event] + 1;         # works, but...
> 
> Is this efficient? I wonder whether R needs to subset the count vector 
> on both sides of the assignment operator (i.e., twice), or whether 
> there's a shortcut like "++" in C, e.g. "count[i]++" or similar?
> 
> Pascal
> 
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic