Code Monkey home page Code Monkey logo

rstudioconf2019's Introduction

RStudioConf2019

My presentation at RStudio::conf(2019), Austin, Tx - "The lazy and easily distracted report writer" on 18th January 2018.

Aims

The example provided shows how you can use parameters with rmarkdown and knitr to produce reports for multiple outcomes.

Specifying parameters for knitr / rmarkdown

We're using a parameter passed into the report via the YAML header. This parameter can be set at time of rendering the report (using the knit with parameters option in the RStudio IDE, via "Inputs" specification in RStudio Connect or by specifying the parameters and values within a list passed to the params argument of rmarkdown:render.

Quantitative vs non-quantitative view

If the user sets the quantAudience parameter to FALSE then the code is hidden in the rendered HTML, and certain text sections are hidden. To hide text we keep the relevant text in child documents and only bring these into the report if the quantAudience parameter is set to TRUE. The code is entirely contained in the parent document, but is executed depending on the setting of the parameter.

Working with more than one outcome endpoint

The trick is to rename the outcome variables (and potentially associated variables with the same name e.g. HAMDTL17_BASE, HAMDTL17_CHG) to something generic i.e. outcome that will allow us to write code once and use it for each of the endpoint variables. We can then use the endpoint parameter params$endpoint to specify labels and names wherever these are needed. We could also compute based on the value of params$endpoint if we need to do specific things for each endpoint e.g. if one outcome is binary, rather than continuous.

rstudioconf2019's People

Contributors

mikeksmith avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.