You can easily reproduce the parse behavior with:
str <- "3a" parse(text = str)
parse try to parse your str as a variable name. Either you must indicate the available variable name, either it should not start with a digit, or you must put it between ``. following works:
str <- "`3a`" parse(text = str)
and in your example, this also works:
str <- "abc12-`3def`" parse(text = str)
Finally, for your second example, it is logical that it will not work, since you are not giving an accessible expression for parsing:
str <- "abc123-"
if yours is just a line separator, why not convert it to _ ? eg:
parse(text=gsub('-','_',str))
source share