stri_list2matrix #105

Closed
gagolews opened this Issue Oct 23, 2014 · 0 comments

Comments

Projects
None yet
1 participant
@gagolews
Owner

gagolews commented Oct 23, 2014

Convert a list of atomic vectors to a character matrix

Unlike simplify2array always return a matrix.

Possible scenarios:

> stri_list2matrix(list(c("a", "b"), c("c", "d"), c("e", "f")))
     [,1] [,2] [,3]
[1,] "a"  "c"  "e" 
[2,] "b"  "d"  "f" 
> stri_list2matrix(list(c("a", "b"), c("c", "d"), c("e", "f")), byrow=TRUE)
     [,1] [,2]
[1,] "a"  "b" 
[2,] "c"  "d" 
[3,] "e"  "f" 
> stri_list2matrix(list("a", c("b", "c")))
     [,1] [,2]
[1,] "a"  "b" 
[2,] NA   "c" 
> stri_list2matrix(list("a", c("b", "c")), fill="")
     [,1] [,2]
[1,] "a"  "b" 
[2,] ""   "c" 

Useful in connection with stri_extract and stri_split

@gagolews gagolews self-assigned this Oct 23, 2014

@gagolews gagolews added this to the stringi-0.3 milestone Oct 23, 2014

gagolews added a commit that referenced this issue Oct 23, 2014

@gagolews gagolews closed this Oct 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment