[R] help: program efficiency

Roman Luštrik roman.lustrik at gmail.com
Fri Nov 26 20:21:33 CET 2010


See if this works for you.

a <- c(2,1,1,3,3,3,4)
a.fac <- as.factor(a)
b <- split(a, f = a.fac)
system.time(lapply(X = b, FUN = function(x) {
			swn <- seq(from = 0, to = 0 + 0.01*length(x), by = 0.01)
			out <- x + swn
			return(out)
		}))

Cheers,
Roman
-- 
View this message in context: http://r.789695.n4.nabble.com/help-program-efficiency-tp3059079p3060801.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list