r - regex variable substitution in "replacement" argument -
I have a string in R. I want to find the part of the string and add a variable number of zero. For example, I have I have a mind code like this: Code returns One way But this is a little clunky. Try operator associated with package: 1 2 3 . Sometimes I want to be it
1 203 ; Sometimes I want it to be
1 2000 3 . If I store the number of the enclosed ones in a variable, then how can I use it in the "Replacement" part of the
sub command?
s < - '1 2 3' z & lt; - '3' sub ('(\\ s \\ d) (\\ s. *)', '\\ 10 {Z} \\ 2', s)
1 20 {z} 3 . But should I get the code like this?
s <- '1 2 3' z
required (string ) "abc"% stri +% "123abc" ## [1] "abc123abc"
Comments
Post a Comment