Hi R-helpers,

I have a character string, for example:

"lm(y ~ X2 + X3 + X4)"

from which I would like to strip off the leading and trailing
quotation marks resulting in this:

lm(y ~ X2 + X3 + X4)


I have tried using gsub() but I can't figure out how to specify the
quotation mark using a regular expression.

Alternatively, I would like a function that lets me delete the leading
(or trailing) X characters, and in this case X=1 (but it could be used
more flexibly to delete several leading or trailing characters).

I would appreciate help with either of these potential solutions (gsub
and regex, or delete leading/trailing characters).

Many thanks!

Mark

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to