search for: splitwithnames

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

2004 Apr 08
1
Why are Split and Tapply so slow with named vectors, why is a for loop faster than mapply
...<- split(actTime, chainId)) Timing stopped at: 83.22 0.12 84.49 NA NA The same thing happens with using tapply with a named vector such as: tapply(actTime, chainId, function(x) x) Using the following function with a for loop accomplishes the job in a few seconds for all 70,000+ records: > splitWithNames <- function(dataVector, nameVector, factorVector){ + dataList <- split(dataVector, factorVector) + nameList <- split(nameVector, factorVector) + listLength <- length(dataList) + namedDataList <- list(NULL) + for(i in 1:listLength){ + x <- dataList[[i]]...