On Wed, 19 Oct 2016, g.maub...@weinwolf.de wrote:

Hi All,

I would like to store a long string with white space in a variable:

-- cut --
 # Create README.md
 readme <- "---
title: "Your project title here"
author: "Author(s) name(s) here"
date: "Current date here"
output: html_document
---

[snip]

"
cat(readme, file = "README.md")

-- cut --

I am looking for an equivalent to Pythons """  """ long string feature.


Whitespace isn;t the issue here. Embedded quotes are the problem.

See

        ?Quotes

In this case, if your replace the first and last double quotes with single quotes, you will get a single string of 464 characters, which is what you want.

In other cases where you have embedded single quotes, you can escape them and the double quotes and get what you want.

[snip]

PS: This is a template for a project folder for each project. I would like
to create it with R script instead of distributing it as a template file.
This way one needs only the R script to setup a project like this:


[rest deleted]

There are templating procedures available. Package brew might be worth a look. It can take a template string with embedded R code and return a string with the R results spliced in. Package knitr has some ability to deal with templates, too, and I think there are other packages.

Jeff Newmiller's suggestion to make a package seems right to me whether you use brew or not. Long term it will probably be the easiest path.

HTH,

Chuck

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to