Dear marc: thank you for your tip.
> > cat(x.new, "\n")
> 3\',5\'-cyclic-nucleotide phosphodiesterase activity
>
here cat is printing on screen.
how can I direct the output to an object.
I cannot do:
y <- cat(x.new, "\n")
is there any other way.
thanks
srini
> Try this:
>
> x <- "3',5'-cyclic-nucleotide phosphodiesterase
> activity"
>
> > x
> [1] "3',5'-cyclic-nucleotide phosphodiesterase
> activity"
>
> > gsub("'", "\\\\'", x)
> [1] "3\\',5\\'-cyclic-nucleotide phosphodiesterase
> activity"
>
>
> Note that I use gsub() to replace both instances of
> the ', whereas sub()
> will only replace the first.
>
> The escape character itself needs to be escaped when
> used within the
> replacement regex, since the "\" is a metacharacter.
> You end up with
> four "\"s since R also treats the "\" specially.
>
> When you cat() the output, you get:
>
> > x.new
> [1] "3\\',5\\'-cyclic-nucleotide phosphodiesterase
> activity"
>
> > cat(x.new, "\n")
> 3\',5\'-cyclic-nucleotide phosphodiesterase activity
>
>
> HTH,
>
> Marc Schwartz
>
>
>
______________________________________________
[email protected] 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.