[R] Is it possible to remove this loop? [SEC=UNCLASSIFIED]

Jin.Li at ga.gov.au Jin.Li at ga.gov.au
Wed Jul 4 02:23:34 CEST 2012


Thank you all for providing various alternatives. They are all pretty fast. Great help! Based on a test of a dataset with 800,000 rows, the time used varies from 0.04 to 11.56 s. The champion is:
> a1$h2 <- 0
> a1$h2[a1$h1=="H"] <- 1
Regards,
Jin

Geoscience Australia Disclaimer: This e-mail (and files transmitted with it) is intended only for the person or entity to which it is addressed. If you are not the intended recipient, then you have received this e-mail by mistake and any use, dissemination, forwarding, printing or copying of this e-mail and its file attachments is prohibited. The security of emails transmitted cannot be guaranteed; by forwarding or replying to this email, you acknowledge and accept these risks.



More information about the R-help mailing list