Try this:

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

To remove X characters:

gsub("^.|.$", "", "lm(y ~ X2 + X3 + X4)")


On Tue, Dec 14, 2010 at 6:27 PM, Mark Na <mtb...@gmail.com> wrote:

> 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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

        [[alternative HTML version deleted]]

______________________________________________
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