https://github.com/davidasmith/docmerge
https://github.com/davidasmith/docmerge
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/davidasmith/docmerge
- Owner: DavidASmith
- License: other
- Created: 2025-09-01T07:47:12.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-10-03T12:22:00.000Z (10 months ago)
- Last Synced: 2025-10-03T14:31:50.090Z (10 months ago)
- Language: R
- Size: 31.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# docmerge
docmerge helps you to generate multiple Microsoft Word documents from R. You can use a Word document as a template, with placeholders for text to be filled in from R. docmerge will create a separate Word document for each row of input data you provide.
## Installation
You can install the development version of docmerge [GitHub](https://github.com/DavidASmith/docmerge) with:
``` r
# install.packages("devtools")
devtools::install_github("DavidASmith/docmerge)")
```
## Example
Create a Word document to use as a template, with placeholders for the text you want to change in each output document. By default, placeholders are indicated by double angle brackets, e.g. `<>`.
An example template is included with the package. Its path can be found like this:
``` r
example_template <- system.file(
"extdata",
"letter_template.docx",
package = "docmerge"
)
```
Then create a data frame with the data to fill in the placeholders. Column names must match the placeholders in your template. An example data frame is included in the package:
``` r
gift_details
```
Then use docmerge to generate documents (one for each row in the data frame):
``` r
docmerge(default_template, gift_details)
```
Output Word documents are written to the current working directory. You can specify an alternative using the `output_path` argument.
Note that you can specify the output file name by including a column named `file_name` in your data frame. If this is absent, files will be named `1.docx`, `2.docx`, etc.