Displaying 1 result from an estimated 1 matches for "nameddatalist".
2004 Apr 08
1
Why are Split and Tapply so slow with named vectors, why is a for loop faster than mapply
...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]]
+ names(x) <- nameList[[i]]
+ namedDataList[[i]] <- x
+ }
+ namedDataList
+ }
> system.time(actTimeList <- splitWithNames(actTime, zoneNames, chainId))
[1] 8.04 0.00 9.03 NA...