yes, yes! I'm out of my mind. Thank you. -----Original Message----- From: hadley wickham [mailto:[EMAIL PROTECTED] Sent: Saturday, September 20, 2008 5:49 PM To: Ling, Gary (Electronic Trading) Cc: r-help@r-project.org Subject: Re: [R] fast value replacement in (numeric) vector
On Sat, Sep 20, 2008 at 4:41 PM, Ling, Gary (Electronic Trading) <[EMAIL PROTECTED]> wrote: > Hi R users, > What is the fastest way to replace a(some) value(s) in a (numeric) > vector? > I checked ?replace, but its output is another vector. > 1) I wonder if there's any function to perform in-place replacement? > 2) Or any other function would do what I'm looking for with faster > speed? > > # here is something I tried in R: > n <- 100000 > L <- 1:n L[1] <- 0 L[n] <- 0 L[c(1, n)] <- 0 ? Hadley -- http://had.co.nz/ -------------------------------------------------------- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. ______________________________________________ R-help@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.