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.
______________________________________________
[email protected] 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.