[R] how to wrap a long line in R scripts?
Jonathan P Daily
jdaily at usgs.gov
Mon Jan 10 16:00:40 CET 2011
Oops! Good catch. I have been coding in python and R recently and now I'm
mixing conventions ... R's automatic line wrapping and Python's
auto-catenation given a line wrap (via '\').
A better solution would be:
a <- paste("reaaaaaaaaaaaaaaaallllllllyyyyy looooo",
"ooooooooong chaaaaaaaaarrr", sep = "")
print(a)
--------------------------------------
Jonathan P. Daily
Technician - USGS Leetown Science Center
11649 Leetown Road
Kearneysville WV, 25430
(304) 724-4480
"Is the room still a room when its empty? Does the room,
the thing itself have purpose? Or do we, what's the word... imbue it."
- Jubal Early, Firefly
r-help-bounces at r-project.org wrote on 01/10/2011 09:51:28 AM:
> [image removed]
>
> Re: [R] how to wrap a long line in R scripts?
>
> Keith Jewell
>
> to:
>
> r-help
>
> 01/10/2011 09:54 AM
>
> Sent by:
>
> r-help-bounces at r-project.org
>
>
> "Jonathan P Daily" <jdaily at usgs.gov> wrote in message
>
news:OF588E803B.869E9AFF-ON85257814.004D298D-85257814.004D4FB5 at usgs.gov...
> >a <- "reaaaaaaaaaaaaaaaallllllllyyyyy looooo
> > ooooooooong chaaaaaaaaarrr"
> >
> > Although the indentation is just personal preference.
> > --------------------------------------
> > Jonathan P. Daily
> > Technician - USGS Leetown Science Center
> > 11649 Leetown Road
> > Kearneysville WV, 25430
> > (304) 724-4480
> > "Is the room still a room when its empty? Does the room,
> > the thing itself have purpose? Or do we, what's the word... imbue it."
> > - Jubal Early, Firefly
> >
>
> Did you test that? Printing a to see the result so the commands are
> -------------
> a <- "reaaaaaaaaaaaaaaaallllllllyyyyy looooo
> ooooooooong chaaaaaaaaarrr"
> a
> ----------------------------
> Pasting directly into Rgui
> > a <- "reaaaaaaaaaaaaaaaallllllllyyyyy looooo
> + ooooooooong chaaaaaaaaarrr"
> > a
> [1] "reaaaaaaaaaaaaaaaallllllllyyyyy looooo\n ooooooooong
> chaaaaaaaaarrr"
>
> Saving to file 'test.r' and sourcing
> > source("C:\\Documents and Settings\\jewell\\Desktop\\test.r",
echo=TRUE)
> > a <- "reaaaaaaaaaaaaaaaallllllllyyyyy looooo
> + ooooooooong chaaaaaaaaarrr"
> > a
> [1] "reaaaaaaaaaaaaaaaallllllllyyyyy looooo\n ooooooooong
> chaaaaaaaaarrr"
>
> I don't think this is what the OP wanted.
> I guess he wants "reaaaaaaaaaaaaaaaallllllllyyyyy loooooooooooooong
> chaaaaaaaaarrr"
>
> I don't know the answer (other than, as suggested by Peter Ehlers") to
build
> it bit by bit.
>
> KJ
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list