Quantcast
Channel: Is there a best way to append a list values to a sublist of a list in R? - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by Julian for Is there a best way to append a list values to a sublist...

A purrr way:l <- list(c(1,2,3), c(2,1,4), c(4,7,6))a <- list(3,5,7)purrr::map2(l,a, append)Output:[[1]][1] 1 2 3 3[[2]][1] 2 1 4 5[[3]][1] 4 7 6 7

View Article



Answer by user2974951 for Is there a best way to append a list values to a...

Yesmapply("c",l,a,SIMPLIFY=FALSE)[[1]][1] 1 2 3 3[[2]][1] 2 1 4 5[[3]][1] 4 7 6 7

View Article

Is there a best way to append a list values to a sublist of a list in R?

Say I have a list l containing sublists, and I would like to add an element of a list at the end of each sublist of that list.> l <- list(c(1,2,3), c(2,1,4), c(4,7,6))> l[[1]][1] 1 2 3[[2]][1]...

View Article
Browsing all 3 articles
Browse latest View live


Latest Images