Re: [R] multiline string continuation

From: Erik Chang <audachang_at_gmail.com>
Date: Wed 18 Oct 2006 - 17:22:39 GMT

Great! It works.

Erik

On 10/18/06, Gabor Grothendieck <ggrothendieck@gmail.com> wrote:
> May this:
>
> gsub("\n", "", "
> X:/level1/level2
> /level3/level4/
> level5/level6
> ")
>
> On 10/18/06, Erik Chang <audachang@gmail.com> wrote:
> > Dear R experts,
> >
> > I wonder how can one input a string variable in multiple lines in a R
> > script. I've seen solution to the command line continuation in the
> > non-string situation (just continute at the new line). However, that
> > doesn't work for strings because the new line character, "\n", is
> > included in the resultant string. For example, if I type the following
> > in a script:
> >
> > datadir=" X:/level1/level2
> > /level3/level4/
> > level5/level6"
> >
> > after executing the script, string variable "datadir" becomes
> >
> > "X:/level1/level2\n/level3/level4/\nlevel5/level6"
> >
> > Someone has suggested to use "paste()" for putting pieces of strings
> > together, but I would like to see if there is any other simpler
> > workaround for multiline string continuation.
> >
> > Best,
> >
> > Erik
> >
> >



R-help@stat.math.ethz.ch 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. Received on Thu Oct 19 03:54:11 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 18 Oct 2006 - 19:30:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.