Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Including (sub) documents #1

Closed
vnijs opened this issue Mar 2, 2015 · 3 comments
Closed

Including (sub) documents #1

vnijs opened this issue Mar 2, 2015 · 3 comments

Comments

@vnijs
Copy link

vnijs commented Mar 2, 2015

Saw your blog plots. Thanks for putting that together. FYI a convenient way to include (sub) documents in another Rmd file is to use the child option (http://stackoverflow.com/a/17605475/1974918)

@lmmx
Copy link
Owner

lmmx commented Mar 2, 2015

Ah thank you so much! As I guess you read I was considering running brew on an intermediate to write the YAML list of what to include: - since the child option seems to take a character vector, I'm sure I could run list.files() and supply the list programmatically through that instead... Hmm...

@vnijs
Copy link
Author

vnijs commented Mar 2, 2015

That should work I think. There are really powerful tools to create documents with r and markdown but imho they lack simple examples to help users get started. hadley/rsmith , for example, seems really interesting but it is not very clear how to use whisker tempting with rmarkdown documents. Anyway, keep posting!

Ah thank you so much! As I guess you read I was considering running brew on an intermediate to write the YAML list of what to include: - since the child option seems to take a character vector, I'm sure I could run list.files() and supply the list programmatically through that instead... Hmm...

Reply to this email directly or view it on GitHub:
#1 (comment)

@lmmx
Copy link
Owner

lmmx commented Mar 3, 2015

Code chunk now in the example file analysis.Rmd rather than the YAML includes: header :

```{r child = c("analysis-i.md", "analysis-ii.md", "analysis-iii.md")}
# The 'children' of the 'main' document can be specified (with the same result as the `include: after_body:` field in the YAML header) with either an explicit list:
#
# ```{r child = c("analysis-i.md", "analysis-ii.md", "analysis-iii.md")}
# ```
#
# or a call to `list.files`:
#
# ```{r child = list.files(pattern = 'analysis-.*?\\.md')}
# ```
# The former is preferable, but NB throws error if pattern doesn't match since child = character(0)
```

Using the explicit list rather than file globbing for now as commented, an if statement would be needed to use list.files, and of note the ordering of Roman numerals would not be as expected based on default list.files alphanumeric ordering (markdown files would be appended out of order).

@lmmx lmmx closed this as completed Mar 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants