You are now being redirected to Orchard Platform Markets, LLC.
If you aren’t redirected in a few seconds click here.
You are now being redirected to Orchard Indexes.
If you aren’t redirected in a few seconds click here.

Subscribe to our Newsletter


  • Investor Portal

  • Originator Database

  • Manager Database

If you forgot your login email, please contact your Orchard Account Manager or

Automated PDF reports using R Markdown

Many of the graphics that we have produced on this blog as well as in collateral for Orchard are built using an open-source statistical software called R. For those who are not familiar with R, it is a simple, dynamic programming language that can be used to generate completely customizable plots that can be updated easily. It has a strong community following, and many data scientists contribute packages that others may find useful, for free! One capability that we have found to be a great tool is the automation of reports using R Markdown.

The R Markdown language is an extension of LaTeX which allows for directly embedding R output into documents such as PDF, HTML, or Word document. For example, we’ve been generating images in R and including them in our blog posts like such:

Origination Amount

With a short wrapper in R Markdown, we can embed the graph in a pdf with the following code:

output: pdf_document

` ` `{r}
loans = get_loans()
` ` `

To keep the markdown file clean, we store the R code that generates the plot in a separate file. R is extremely flexible and allows for customization of everything from date format to axis line style to colors of the bars. In the above chart, we aggregate origination amounts by date to show the trend over time but the stacked bar chart is just one simple example of many different graphics that R can generate.

In R, we commonly work with data tables which allow for quick matrix calculations. There is an excellent R package called pander which is useful for outputting nicely formatted tables into the documents. Pass the table object to the pander function like so:

` ` `{r}
summary_table = summary_by_grade(loans, ‘Prosper’)
` ` `

And R will produce the following table in the document:

Table Screenshot

Putting it all together, after adding a few more plots and stylizing the header and footer, we can use the R Markdown facility to generate a market data report. When we receive new data from originators, we just need to click a button and the code takes care of updating all of the plots and tables automatically! The result is a nicely formatted PDF report that you can download here: Consumer Unsecured Quarterly Profile.

There are a few limitations, and LaTeX is a bit difficult to work with, but the R Markdown facility is by far the best PDF report builder that we have found so far. Any graphic (non-interactive) that can be built in R can be incorporated into the document, and the possibilities are limitless. For more ideas on the types of graphics that R can produce, check out a gallery here: R Gallery.

  • vfulco

    Hello- Any chance you could open source your report template? it has a nice crisp, clean design and I am learning Rmarkdown currently. thank you for considering.

  • Tony Gitonga

    could you be having the R code
    Source Code