Re: [R] mapping between list and vector

2015-10-29 Thread Adams, Jean
Maxim, I'm not sure how much faster this would be ... but you could test it out and see. I defined lngL and result as vectors instead of lists. And I calculated j outside of the "loop". myList <- list(a="key1", b=c("key2","key3"), c="key4") myVec <- c("val1","val2","val3","val4") lngL <- sappl

[R] mapping between list and vector

2015-10-29 Thread Maxim via R-help
Hi, for some reason I have to map elements of a list "myList" (of vectors of different length) to a vector "myVec" as such: myList <- list(a="key1", b=c("key2","key3"), c="key4") myVec <- c("val1","val2","val3","val4") result <- list() lapply(myList,length) -> lngL j <- 1 for (i in 1:(length(l