How to Publish an R Markdown Document to Posit Connect

This guide used RStudio Version 2023.05.0.

This guide walks you through creating a new R Markdown document and then publishing your document to Posit Connect.

Prerequisites

Before you begin, you must:

For more information about requesting permission to publish your content, please see the Publishing section of the User Guide.

Note

As you walk through this guide, there might be additional steps that are required due to your unique environment. For example, you might need to install or update packages, restart R, etc. In many cases, Connect prompts you to complete the action that is required to continue with this guide. If you get stuck, please refer to the Related Documentation section or the Posit Connect Admin Guide.

Step 1. Create a new R Markdown document

RStudio has a sample R Markdown document that is available out of the box. For this guide, we are going to utilize the sample HTML R Markdown document. Everyone has access to it, and it allows us to focus on the task of publishing an R Markdown document to Connect instead of manually creating the document from scratch. Let’s begin!

  • Open RStudio.

  • From the menu bar, select File > New File > R Markdown…. The New R Markdown window displays.

    Screen capture of the RStudio New File options

  • Do the following:

    • Give your document a title.

    • Optionally, give your document an author.

    • Since we are creating an R Markdown document using HTML as the output format, no action is required. However, there are two other default options for R Markdown documents using the Output Format option: PDF and Word.

    • Click OK. The new R Markdown document displays in the editor.

      Screen capture of the New R Markdown configuration window

    Now, we need to Knit the file that generates the document that includes the content as well as the output of any embedded R code chunks included in the document. This step ensures that your document was successfully created and works as intended.

  • At the top of the editor, click Knit. The Save File window displays.

    Knit button

  • In the File name field, type a name for the document.

    Note

    The Save File window that displays might vary based on your OS or version of RStudio.

    • Optionally, you can create a new folder or select an existing folder.

    • Click Save.

    Save button

If the Knit was successful, then your document automatically opens in a new browser tab. If it doesn’t automatically display, your app might have been blocked as a popup in your browser.

Example of the R Markdown document displaying in
  a browser tab

Step 2. Publish your R Markdown document to Connect

Before you execute this step, verify that you have connected your RStudio account. The procedure is available in the Connect your Posit Account how-to guide.

  • At the top of the editor, click Publish. The Publish window displays.

    Screen capture of Publish button

  • Click Posit Connect, then click Publish just this document.

    Screen capture of the first two Publish window screens

  • Click Publish finished document only.

    Screen capture of final Publish window screen

  • In the final Publish window, confirm that your account is shown in the Publish To Account section and click Publish.

    Publish to Server window with user account selected

    User tips
    • You can monitor the status of the deployment in the RStudio Deploy pane.
    • If for any reason you would like to stop the deployment, you can simply click the Stop button located in the Deploy pane.
    • Your newly deployed R Markdown document automatically opens in a new browser tab if the Launch browser check box is selected (it is selected by default).
    • If it doesn’t automatically display, your app might have been blocked as a popup in your browser.

Step 3. View your R Markdown document on Connect

  • Navigate back to the Connect server that you published your content to. If applicable, log back into Connect.

  • To view the Content that you own, click your username, and then click Profile.

    Screen capture of the Profile button selected

  • Your R Markdown document, and any other published content, displays. To view your R Markdown document, simply click the title of your app.

    Screen capture of content being selected

  • Your R Markdown displays in the Connect browser window.

    Screen capture of the published R Markdown document