On Tue, 27 Jul 2010, Prof Brian Ripley wrote : > > Note that raw values in R are really intended to be passed around and not > manipulated: if you do much of the latter, coercing to integer, say, is > likely to be much more efficient. > > Indeed :
I tried a minimal benchmark : a <- charToRaw(paste(citation(), "\002", licence(), "\003", "garbage")) proc.time() for (i in 1:10000) { j0 <- match (as.raw(2), a) j1 <- match (as.raw(3), a) } proc.time() for (i in 1:10000) { b <- as.integer(a) j0 <- match (2, b) j1 <- match (3, b) } proc.time() In this case, the solution using as.integer() looks about 4 time faster. Bruno. [[alternative HTML version deleted]] ______________________________________________ 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.