I try to keep all my R script lines under 80 characters. This can prove to be a challenge whenever strings are involved, but usually just breaking lines without using any special character works, like this:
plot(x, y, main = "some reeeealy long title, so long that
I need to break it into several lines
in order to satisfy my ****-retentive
self.")
However, some functions such as setwd()
just won't let me do this. For example, running
setwd("/folder/another folder/yet another folder/
what are you doing, hiding pr0n?/I think I've made my point/")
Returns the following error:
Error in setwd("/folder/another folder/yet another folder/\n
what are you doing, hiding pr0n?/I think I've made my point/") :
cannot change working directory
I've tried braking line on different points other than at the slash character, but I couldn't get it to work. The only workaround I could find was running
setwd(paste("/folder/another folder/yet another folder/",
"what are you doing, hiding pr0n?/I think I've made my point/",
sep = "")
Which works, but seems like a lot of mess just in order to respect some self-defined rule.
Is there a more elegant way to achieve this?
In general, paste
is the only way I can think of, however, in this special case, file.path
is a better choice than paste
as it provides the right separation character for your platform automatically.
file.path("/folder", "another folder", "yet another folder",
"what are you doing, hiding pr0n?",
"I think I've made my point")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With