[R] Increment element of vector and efficiency
Pascal A. Niklaus
Pascal.Niklaus at unibas.ch
Thu Nov 20 14:43:48 CET 2003
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
More information about the R-help
mailing list