[R] multiline string continuation

Erik Chang audachang at gmail.com
Wed Oct 18 18:53:30 CEST 2006


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



-- 
Erik Chang, PhD
CIHR Group for Action and Perception
The University of Western Ontario
Department of Psychology
Room 6256 Social Science Centre
London, ON, Canada.  N6A 5C2

audachang at gmail.com
http://ulysses.ssc.uwo.ca/

TEL: 1-519-661-2111 ext. 88190.
FAX: 1-519-661-3961



More information about the R-help mailing list