Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (5.3k points)

I want to split a line in an R script over multiple lines (because it is too long). How do I do that?

Specifically, I have a line such as

setwd('~/a/very/long/path/here/that/goes/beyond/80/characters/and/then/some/more')

Is it possible to split the long path over multiple lines? I tried

setwd('~/a/very/long/path/here/that/goes/beyond/80/characters/and/

then/some/more')

with return key at the end of the first line; but that does not work.

Thanks.

1 Answer

0 votes
by

To split code over multiple lines in an R script, you can use the paste0 function from the base package, whose syntax is given below:

paste0(..., collapse = NULL)

In your case:

R> setwd(paste0("~/a/very/long/path/here",

               "/and/then/some/more",

               "/and/then/some/more",

               "/and/then/some/more"))

Browse Categories

...