Create parametric R markdown documentation?

前端 未结 4 1167
盖世英雄少女心
盖世英雄少女心 2020-12-03 06:09

I want to iterate over a list of result-sets in my R markdown file. When I produce the output I want to include some text like headers with the name of the result set.

4条回答
  •  情话喂你
    2020-12-03 06:35

    An alternative solution with pander:

    <% for (res in names(results)) { %>
    ### Results for: <%= res %>
    
    <%=
    plot(results[[res]]$x, results[[res]]$y)
    %>
    <% } %>
    

    And just Pandoc.brew this in one run to get what you were up to:

    > Pandoc.brew('doc.brew')
    
    ### Results for: result1
    
    ![](/tmp/Rtmp4yQYfD/plots/568e18992923.png)
    
    ### Results for: result2
    
    ![](/tmp/Rtmp4yQYfD/plots/568e6008ed8f.png)
    

    Or generate HTML/docx/etc. in one run:

    > Pandoc.brew('doc.brew', output = tempfile(), convert = 'html')
    > Pandoc.brew('doc.brew', output = tempfile(), convert = 'docx')
    

提交回复
热议问题