Skip to content

iterative reporting - docx from dataframe #1

@zoe-xanthellae

Description

@zoe-xanthellae

Thanks for the super helpful content here, I've been looking for something like this to help me iteratively produce reports! I have a few questions about tweaking the functionality of this code:

  • Currently you have information for formatting html/pdf output, is there a way to iteratively create outputs to docx? The ultimate format of my documents is docx using a template docx as specified in the YAML header in the rmd file

  • From my understanding, the example data table, mtcars, has unique car names for the loop to pull from, then grabs data from that cells in other columns in that row for the report. In my dataset (test, see below), I would like to have the loop function over each "doc", printing all the rows in "markd" in order to create a marked down word document (should produce two, blah 1 and blah 2). For reference, this is the chunk settings/code I was previously using in the rmd file to produce one "doc" from this dataframe:

# results='asis', echo=FALSE, warning=FALSE, message=FALSE, evaL=FALSE
doc1 <- test %>% 
filter(., doc == "blah 1")
cat(doc1$markd, sep="\n", fill = 2)

Rendering docx files

If I'm understanding your code correctly, this is what the render code would like in the Rscript file (though I'd want it to print docx files):

for (doc in unique(rownames(test))){
  rmarkdown::render('./Docs/renderReports.Rmd',  # file 2
                    output_file =  paste(doc, ".docx", sep=''), 
                    output_dir = './Docs')

Example data.frame file here:
test.txt

I'm somewhat of an R novice, so let me know if you need any more information!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions