Split character vector, i.e. each element, by a seperator and convert the resulting exploded string into a typed list / data frame of meta information.
str_parse( x, ext = NULL, which = NULL, types, names, as.df = TRUE, append = TRUE, ... )
x | [ |
---|---|
ext | [ |
which | [ |
types | [ |
names | [ |
as.df | [ |
append | [ |
... | [any] |
A data frame or a list (depends on as.df
).
Other string helpers:
str_explode()
,
str_to_shortcut()
x = c("char_int10_num10.4", "char_int28_num30.444") str_parse(x, types = "cin", names = c("character", "integer", "numeric"), split = "_")#> character integer numeric input #> 1 char 10 10.400 char_int10_num10.4 #> 2 char 28 30.444 char_int28_num30.444#> integer numeric input #> 1 10 10.400 char_int10_num10.4 #> 2 28 30.444 char_int28_num30.444str_parse(x, which = 2:3, types = "in", names = c("integer", "numeric"), as.df = FALSE, append = FALSE, split = "_")#> [[1]] #> [[1]]$integer #> [1] 10 #> #> [[1]]$numeric #> [1] 10.4 #> #> #> [[2]] #> [[2]]$integer #> [1] 28 #> #> [[2]]$numeric #> [1] 30.444 #> #>