Re: [R] More efficient way to use ifelse()? - A follow up

2010-05-26 Thread Ian Dworkin
# Thanks again to everyone who provided suggestions. # I was curious about which approaches would be the fastest... so a little benchmarking # My approach was by far the worst :) # The approach suggested by Duncan Murdoch and Peter Langfelder, based on indexing , was by far the fastest (~

Re: [R] More efficient way to use ifelse()? - A follow up

2010-05-26 Thread Joris Meys
Remove the around the options. You also have to put it in a sapply, as switch only works on single values. But I wouldn't call this optimal... elevation.DM -sapply(Population,switch, CO= 2169, CN = 1121, Ga =500, KO = 2500, Mw = 625, Ng = 300 ) Cheers Joris On