# transpose

0th

Percentile

##### Transpose a list.

Tranpose turns a list-of-lists "inside-out"; it turns a pair of lists into a list of pairs, or a list of pairs into pair of lists. For example, If you had a list of length n where each component had values a and b, transpose() would make a list with elements a and b that contained lists of length n. It's called transpose because x[][] is equivalent to transpose(x)[][].

##### Usage
transpose(.l)
##### Arguments
.l

A list of vectors to zip. The first element is used as the template; you'll get a warning if a sub-list is not the same length as the first element. For efficiency, elements are matched by position, not by name.

##### Details

Note that transpose() is its own inverse, much like the transpose operation on a matrix. You can get back the original input by transposing it twice.

• transpose
• zip_n
• zip2
• zip3
##### Examples
# NOT RUN {
x <- rerun(5, x = runif(1), y = runif(5))
x %>% str()
x %>% transpose() %>% str()
# Back to where we started
x %>% transpose() %>% transpose() %>% str()

# transpose() is useful in conjunction with safely() & quietly()
x <- list("a", 1, 2)
y <- x %>% map(safely(log))
y %>% str()
y %>% transpose() %>% str()

# Use simplify_all() to reduce to atomic vectors where possible
x <- list(list(a = 1, b = 2), list(a = 3, b = 4), list(a = 5, b = 6))
x %>% transpose()
x %>% transpose() %>% simplify_all()
# }

Documentation reproduced from package purrr, version 0.2.2.2, License: GPL-3 | file LICENSE

### Community examples

Looks like there are no examples yet.