Open RobinHankin opened 5 years ago
Also,
subs(abc(1:20),'a','zaz')
has a natural interpretation and it would be nice for this too to work as expected.
(coming back to the package after a few months doing other things). The helppage for function subs()
is confusing. I was kind of expecting it to behave a bit like unix grep or sed, as in sed -e s/abc/z/
which would take, say, xabcy
and return xzy
. The examples in subs.Rd
are not optimal for learning what exactly subs()
does. Currently there is no mention of subs()
in the vignette.
Also, note the opening comment for this issue (#18) is also somewhat confusing. It would have been better to ask for subs(abc(1:10),'ab','xy')
to work as expected [viz, substitute a
for x
and then b
for y
].
We should actually be thinking about something like subs(abc(1:10),disord(c('a','b','c'),disord(c('x','y','z'))
although of course this should fail because the hash codes of the second and third arguments are not consistent. Note that this approach would mean that subs(foo, c('a','b'),c('z','aa'))
should also fail, but for a different reason: here the order of the substitution would affect the output. Substituting for a
and then b
would be different from substituting for b
then a
.
Currently,
subs(a,from,to)
requiresto
to be length 1. Butsubs(abc(1:10),abc(5),as.free('opqrs'))
has a natural interpretation and it would be nice for this to work as expected.