R stri_locate_all, Creating a start and end matrix -


i trying create matrix looks this, using stri_locate_all function.

x <- "abcdjakslabcdakjsabcd" m <- stri_locate_all_regex(x, 'abcd') m [[1]]      start end [1,]     1   4 [2,]    10  13 [3,]    18  21 

i tried converting m matrix, seems wrap around wrong way:

output <- matrix(unlist(m), ncol = 2, byrow = true) output      [,1] [,2] [1,]    1   10 [2,]   18    4 [3,]   13   21 

i want output start locations in first column , end locations in second column matrix this.

     [,1] [,2] [1,]     1   4 [2,]    10  13 [3,]    18  21 


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -