search for: codetoelev

Displaying 1 result from an estimated 1 matches for "codetoelev".

2010 May 26
1
More efficient way to use ifelse()? - A follow up
...values[as.numeric(factor(Population))] ) # ~ 0.85s # Values need to be in the order in which the levels of the factor are sorted #i.e. Pop2 <- rep(c("Ga", "CO", "CN", "Ng", "KO", "Mw"), 10) # levels(factor(Pop2)) would not work. #or codeToElev = data.frame(codes = c("CO", "CN","Ga","KO", "Mw", "Ng"), elev = c(2169, 1121, 500, 2500, 625, 300)) system.time( elevation.PL.2 <- codeToElev$elev[match(Population, codeToElev$codes)] )...