rstudio connect: user guide...1.2.1 swaggerdocumentation rstudio connect makes it easy to share your...

39
RStudio Connect: User Guide Version 1.6.6-2 Abstract This guide will help a user configure and deploy content to RStudio Connect. Contents 1 Introduction 1 1.1 Shiny ................................................. 2 1.2 Plumber ................................................ 2 1.3 R Markdown ............................................. 4 1.4 Plots and Graphs ........................................... 5 1.5 TensorFlow Model APIs ....................................... 5 2 Connecting 5 2.1 Update the IDE ............................................ 5 2.2 Connecting Your Account ...................................... 6 3 Publishing 9 3.1 Publishing Instructions for All Content Types ........................... 9 3.2 Publishing Options for Documents ................................. 15 4 API Keys 17 4.1 Examples ............................................... 17 5 R Markdown 20 5.1 Scheduling ............................................... 20 5.2 Report History ............................................ 23 5.3 Output Metadata ........................................... 24 5.4 Output Files ............................................. 24 5.5 Resource Files ............................................. 25 5.6 Email Customization ......................................... 26 6 Shiny 36 6.1 User meta-data ............................................ 36 7 Plumber 36 7.1 User meta-data ............................................ 36 8 Connect Server API Cookbook 37 8.1 Configuring Your Scripts ....................................... 37 8.2 Recipes ................................................ 38 1 Introduction RStudio Connect connects you and the work you do in R with others as never before. Only RStudio Connect provides: “One button” deployment for any Shiny application, R Markdown document, or any static plot or graph to a single environment. 1

Upload: others

Post on 27-Jan-2021

9 views

Category:

Documents


0 download

TRANSCRIPT

  • RStudio Connect: User GuideVersion 1.6.6-2

    AbstractThis guide will help a user configure and deploy content to RStudio Connect.

    Contents1 Introduction 1

    1.1 Shiny . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Plumber . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 R Markdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Plots and Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.5 TensorFlow Model APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    2 Connecting 52.1 Update the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Connecting Your Account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    3 Publishing 93.1 Publishing Instructions for All Content Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Publishing Options for Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    4 API Keys 174.1 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    5 R Markdown 205.1 Scheduling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205.2 Report History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235.3 Output Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.4 Output Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245.5 Resource Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255.6 Email Customization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    6 Shiny 366.1 User meta-data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    7 Plumber 367.1 User meta-data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    8 Connect Server API Cookbook 378.1 Configuring Your Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378.2 Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    1 Introduction

    RStudio Connect connects you and the work you do in R with others as never before. Only RStudio Connectprovides:

    • “One button” deployment for any Shiny application, R Markdown document, or any static plot orgraph to a single environment.

    1

    http://shiny.rstudio.comhttp://rmarkdown.rstudio.com/

  • • The ability to manage and limit access to the work you’ve shared with others - and easily see the workthey’ve shared with you.

    • “Hands free” scheduling of updates to your documents and automatic email distribution.

    For more information on running RStudio Connect in your organization please visit https://www.rstudio.com/products/connect/.

    1.1 Shiny

    Shiny is a web application framework for R that can help turn your analyses into interactive web applications.Get started by following the Shiny tutorial then visit the gallery for inspiration to use in your own dynamicvisualizations.

    RStudio Connect hosts your Shiny applications, allowing colleagues to interact with your data.

    1.2 Plumber

    Plumber is an R package that makes it easy to create API endpoints from annotated R code. For example:## hello-world/plumber.R

    #* @get /helloEndpoint

  • 1.2.1 Swagger Documentation

    RStudio Connect makes it easy to share your API documentation using swagger. First, you willneed at least Plumber version 0.4.0. The latest stable release of Plumber can be installed withinstall.packages("plumber").

    If you do not define a GET / handler, RStudio Connect will provide one that redirects to GET /__swagger__,a special link in Plumber that redirects to Swagger UI. To disable this, define a handler for GET /.

    3

  • 1.3 R Markdown

    R Markdown is an authoring format that enables easy creation of dynamic documents, presentations, andreports from R. It combines the core markdown syntax with embedded R code chunks.

    RStudio Connect helps you publicize and distribute your R Markdown documents. Content is published tothe server, where colleagues can view your work. Documents can be periodically regenerated with the resultsdistributed via email.

    4

    http://rmarkdown.rstudio.comhttp://daringfireball.net/projects/markdown/basics

  • 1.4 Plots and Graphs

    R has very powerful plotting and graphing capabilities. With packages like ggplot2, it is easy to producecomplex, multi-layered graphics.

    RStudio Connect helps you share your plots and graphs by hosting that content.

    1.5 TensorFlow Model APIs

    Deploying your saved TensorFlow model to Connect is easy. Once your model has been trained, save it to adirectory:# `library(tensorflow)` versionexport_savedmodel(session, "mysavedmodel")

    # `library(keras)` versionexport_savedmodel(model, "mysavedmodel")

    That directory can be deployed to connect. See Section 3.1.2

    2 Connecting

    If you have already connected your RStudio IDE, see Section 3 to learn how to publish content toRStudio Connect.

    2.1 Update the IDE

    At the time of this writing, you will need to install at least version 1.0.44 of the RStudio IDE to interact withConnect. You can confirm this by opening the IDE and clicking “Help” > “About RStudio” and checking theversion number at the top of that pane. If you are not running at least version 1.0.44, you should downloadthe latest release.

    5

    http://ggplot2.org/https://www.rstudio.com/products/rstudio/download/https://www.rstudio.com/products/rstudio/download/

  • 2.2 Connecting Your Account

    You’ll need to connect your IDE to Connect and authorize the IDE to use your Connect account. To add apublishing account to RStudio Connect, click Tools then Global Options. . . in the file menu.

    6

  • This will open up the options menu, at which point you can click the Publishing icon on the sidebar, andthen the Connect. . . button to create a new account.

    7

  • Select that you want to configure an RStudio Connect account then enter the address of your server. YourConnect administrator can provide you with the address of the RStudio Connect server.

    The optional nickname is helpful when managing multiple Connect accounts.

    Clicking Next will open up a login window for RStudio Connect.

    8

  • Log into Connect and authorize the IDE to deploy on your behalf.

    You have successfully configured the RStudio IDE and are ready to publish content to RStudio Connect! SeeSection 3.

    3 Publishing

    Be sure to configure your Connect account before attempting to publish with the RStudio IDE.See Section 2 for information on configuring your Connect account

    3.1 Publishing Instructions for All Content Types

    RStudio Connect accepts Shiny applications, R Markdown documents, as well as plots and graphs. The bluepublishing icon in the RStudio IDE indicates that a particular piece of content can be published.

    You can find the blue publishing icon at the following locations:

    • The upper right of the file editor• The document viewer when viewing a document• The embedded viewer when running a Shiny application• The plots pane

    9

  • Click on this icon to open a publishing dialog where you can name your content and select additional files toinclude in the deployment. By default, RStudio will try to infer the data files and scripts are used in yourapplication. This window lets you refine those file selections.

    Most of the time, RStudio is able to determine automatically which files are needed to render your documenton Connect. However, there are situations in which it will miss a file (for instance, if it isn’t referenceddirectly in your document). The Add More. . . button lets you add files to the bundle that will be sent toConnect so that they will be available on the server when your document is rendered. You can also use theresource_files field in your document’s YAML header to add additional files.

    Deployed data files must be in the same directory as your Shiny application or R Markdown document. Filesstored elsewhere on your computer (C:\Users\me\mydata.csv) will not be available on the remote server.

    Click Publish after verifying your settings.

    Your first deployment may take a few minutes, as Connect attempts to recreate the R library you use locally– referenced packages are downloaded and installed. These packages are cached on the server; subsequentdeployments will be faster.

    Not all of your IDE environment can be replicated on the server. Different operating systems or versionsof R can occasionally make applications behave differently. Package installation failures may require theinstallation of additional system libraries.

    When the deployment completes, you’ll be taken to the application’s settings page in RStudio Connect.

    10

  • This page lets you verify the sharing and visibility of your content. Click Publish to confirm these settings.

    Content cannot be viewed until it is published.

    11

  • You should now see your deployed content – a rendered version of the document or a live instance of yourShiny application. The content is displayed within the context of RStudio Connect, and you are able tofurther configure settings for your content.

    3.1.1 Publishing Plumber APIs

    Plumber APIs have the following known restrictions:

    • Push-button publishing from the IDE is not supported• Server-side latency is not tracked

    To get started with publishing Plumber API endpoints, create a directory with a plumber.R file defining yourendpoints. From the console, execute the following, replacing with your project’s directory:

    > rsconnect::deployAPI(api = '')

    Once live, the content view will show you the results of your @get / endpoint. If @get / is not defined, youwill see a “Swagger UI” presentation of your API. Swagger is an API documentation format; Plumber canautomatically generate a swagger.json definition for your API by inspecting your endpoints. The “SwaggerUI” page offers an interactive portal into your API that allows you to test your endpoints directly from thebrowser.

    To make a call to your new API yourself, you’re going to need the target URL. You can find it by looking atthe bottom of the Access tab in your API’s settings, or by clicking the ... menu in the upper-right of thecontent view and select “Open Solo”.

    12

  • The location should look like the following:

    https://example.com/content/42/

    All calls can be made relative to this path. For example, if you want to make a request to /volcano, thelocation in the above example would be https://example.com/content/42/volcano, like so:curl -XPOST https://example.com/content/42/volcano --data-binary '{ "line_plot": true }'

    If your API restricts access to a particular set of users, then Connect will require that incoming requestsauthenticate the user making the request. The best approach for authenticating a request targeting an APIis to use API Keys 4.

    Alternatively, if your server is configured to use proxy authentication, you should ask your IT Administratorabout ways to make API calls through that proxy.

    If you want to perform access control in your Plumber API itself, or if you want to allow anyone to access yourAPI, open the application settings, then the “Access” tab, and set “Who can view this API” to “Anyone”.

    Some configurations may prohibit the “Anyone” access type.

    A simple way to control access might be like the following:#* @filter shared-secret-authkeyAuth

  • res$status

  • Your TensorFlow Model API will return the predicted values as you configured it. For example, if your modelwas configured to respond with a 0-tensor (scalar) of floats, you might get the following:{

    "predictions": [1.2]}

    The rstudio/tfdeploy repository contains some example scripts for building and exporting simple models, soyou can try them before you upload some of your own. For example:account

  • 3.2.2 Publish Source Code

    You will see these options when publishing from the document viewer.

    Publishing the document with source code means that your R Markdown file (.Rmd) will be deployed toRStudio Connect. This file is rendered (usually to HTML) on the server.

    Publishing only the finished document means that the HTML file you rendered locally is deployed to RStudioConnect.

    We recommend publishing your documents with source code, as it allows you to re-render the documentwith RStudio Connect (on a weekly schedule, for example). If the document cannot be rendered by RStudioConnect because of files or data sources that are unavailable on the server, choose “Publish finished documentonly” so others can view your work.

    3.2.3 Document Selection

    You will see these options when publishing an R Markdown document from a directory that contains morethan one R Markdown document. It is possible to link together multiple R Markdown documents to make

    16

  • a multi-page document, so this is your chance to indicate that you’ve done this, and to publish all thedocuments at once. In most cases however you’ll want to publish just the current document.

    4 API Keys

    API Keys allow you to programmatically access content on RStudio Connect, as well as the Connect ServerAPI. They are a substitute for logging in to RStudio Connect to access content.

    API Keys are not associated with any content, and can be used to access any content that the owning usercould access while logged in. The best practice is to create a new API Key for each external tool that needsaccess to content hosted on RStudio Connect, and to give each Key a name that helps you identify the toolthat uses it. When the tool no longer needs access, or if you cannot trust the Key at any time, you canquickly revoke access by deleting the Key.

    To access content with an API Key you must provide a HTTP header whose key is Authorization and valueis Key THE_API_KEY.

    All requests to content must be made to the target URL of the published content. You can find the targetURL by clicking the ... menu in the upper-right of the content view and select “Open Solo”.

    4.1 Examples

    4.1.1 Creating and Deleting an API Key

    To create an API key, click on the circular picture in the top-right portion of the screen. The picture mayhave your username next to it if you are viewing RStudio Connect on a large screen. Click the “API Keys”item in the menu that appears, and you should be taken to the API Keys page.

    17

  • Figure 1: Dialog titled “Create API Key” with the name “my_api_key” entered

    On the API Keys page, click “New API Key”. You will be prompted to name your API key.

    After creating an API key, you will be shown the key and given an opportunity to put it in a safe location.Once you close the dialog, you will NOT be shown the API key again. This helps to keep your user accountsafe.

    18

  • If you have lost an API key, or if you simply don’t need to use the API key anymore, remove the API key byclicking the trash bin icon on the far right column of the API key list.

    When you click the trash bin icon, a dialog will ask you to confirm that you want to delete the API key.Successfully deleting the API key will show a green status message at the top of the screen.

    4.1.2 Static Content

    Suppose you have published a plot whose target URL is http://example.com/content/24/target.html

    You can download the content with an API Key via:curl -o output.html -H 'Authorization: Key YOUR_API_KEY_HERE' \

    'http://example.com/content/24/target.html'

    4.1.3 Plumber

    Suppose you have published the following Plumber application whose target URL is http://example.com/content/42## plumber.R

    #* @get /meannormalMean

  • 4.1.4 Connect Server API

    Examples for using the Connect Server API can be found in the Connect API Cookbook section: 8.

    5 R Markdown

    5.1 Scheduling

    R Markdown reports that are published with source code can be re-executed by RStudio Connect. See section3.2.2 to learn how to publish with source code.

    Re-executing content can either be done manually or on a schedule. After navigating to the “Schedule” panein the configuration window, you might see “The source code for this content was not published. The outputcannot be refreshed.” If this is the case, then you will need to publish source code before it is possible toschedule your content.

    Similarly, Shiny applications or R Markdown documents with a Shiny runtime (Shiny documents) cannot bescheduled. Shiny assets show the latest data each time they are refreshed.

    In other cases the Schedule pane provides options to schedule your asset for execution on RStudio Connect.

    20

    https://rmarkdown.rstudio.com/authoring_shiny.html

  • 21

  • 5.1.1 Date and Time

    The start date and time defaults to the current user’s date, time, and time zone. The schedule will be builtoff of this date and time. Take care to keep in mind how daylight savings time (DST) might affect the actualexecution time of the report.

    If you choose a start date and time in the past, execution will begin at the first future execution that satisfies“Schedule Type,” measured from the time that changes are saved.

    5.1.2 Schedule Type

    The schedule type and related fields will determine how frequently the R Markdown document is executed byRStudio Connect. Using the “Date and Time” above as an anchor, “Schedule Type” defines the time intervalbetween executions.

    The following interval configurations are all supported:

    • defined in minutes– e.g.: “every 15 minutes”– e.g.: “every 90 minutes”

    • defined in hours– e.g.: “every 3 hours”– e.g.: “every 25 hours”

    • defined in days– e.g.: “every 2 days”– e.g.: “every 40 days”

    • every weekday– e.g.: “Monday, Tuesday, Wednesday, Thursday, Friday”

    • defined in weeks (on select days of the week)– e.g.: “every 2 weeks on Tuesday and Thursday”– e.g.: “every 8 weeks on Friday”

    • semi-monthly (1st and 15th)– e.g.: “on the 1st and 15th of every month”

    • semi-monthly (14th and last)– e.g.: “on the 14th and last day of every month”

    • monthly on a given day of the month– e.g.: “every 2 months on the 3rd”– e.g.: “every 8 months on the 30th”

    • monthly on a week / day– e.g.: “every 3 months on the 3rd Tuesday of the month”– e.g.: “every 9 months on the 1st Saturday of the month”

    • defined in years– e.g.: “every 2 years”– e.g.: “every 8 years”

    5.1.3 Publish Output

    When content executes, you can decide whether or not the output should be saved and published to RStudioConnect. If you opt not to have output published after it is generated, any emails will be sent and anyside-effects such as database writes will occur, but the report output will not be saved on Connect. Further,there will be no output history (See section 5.2).

    22

  • In order to save and publish output, as well as track the history of output on Connect, keep the “PublishOutput” box checked.

    5.1.4 Send Email

    This section of the Schedule configuration determines if and where emails will be delivered after execution. Ifchecked, the owner of the content will always be notified unless they opt out. Further, content output can besent to:

    • all collaborators• all viewers• named additional recipients

    By default the rendered content will be attached and RStudio Connect will generate a standard subjectline and email body. For more information on the ability to customize this email, see the section on emailcustomization.

    If you are having difficulty sending emails, contact your RStudio Connect administrator.

    5.2 Report History

    You can view past renders of R Markdown content in RStudio Connect using the History tool. This includesboth manually triggered and scheduled execution of content (See section 5.1).

    To access the history of an R Markdown report, browse to the “More” button (indicated by ellipsis in a circle)and select “History.”

    This will open up a dialog to select the output bundles from previous executions of this report. The latestexecution is in bold and the currently visible version of the output is highlighted.

    Different variants of a parameterized report will have a separate rendering history associated with them.

    23

  • Each collection of output is saved to disk and is available at a unique URL, along with any output files (Seesection 5.4). Permissions for saved output will be the same as permissions for the “parent document” and thesource code that is stored on Connect.

    5.3 Output Metadata

    We normally think of R Markdown documents as producing a single output artifact, such as an HTML orPDF file. The rmarkdown package allows report authors to emit additional output metadata from theirreport. RStudio Connect takes advantage of this metadata, allowing output files, custom email subjects, andadditional email attachments.

    There are two ways to set output metadata: in the YAML header and in R code chunks.

    The YAML header is a good place to configure default values for metadata that you always want to emit. Alloutput metadata lives under the rmd_output_metadata section in the YAML:---title: "Report Title"rmd_output_metadata:

    rsc_email_subject: Quarterly Department Metrics---

    You can also use R code to set output metadata. This is useful if you want metadata to vary based onconditions or variables within your code.changePercent

  • Connect will not process any output files that exist outside the working directory of the report that isrendering. That means that you cannot use absolute paths (e.g., /root/file.csv), relative paths (e.g.,../file.csv) or subdirectories (e.g., folder/file.csv).

    5.4.2 How to Work with Output Files

    There are two ways to specify which files should be treated as output files. The first is to list the file namesin the R Markdown YAML header’s rmd_output_metadata section under rsc_output_files, like so:---title: "Report Title"rmd_output_metadata:

    rsc_output_files:- "data.csv"

    ---

    rsc_output_files takes a list of names of files that should be available after the report has rendered. If youlist a file that does not exist after rendering your report, Connect will log a message but continue trying toprocessing the other files listed. If the output files are not generated during the rendering of your report,then you will also need to list them as resource files when you upload your report to Connect. For moreinformation on resource files, see Section 5.5.

    It is also possible to specify the list of output files from R code. For example:rmarkdown::output_metadata$set(rsc_output_files = list("data1.csv", "data2.csv"))

    You can also make a link to share an output file from your report using the standard Markdown links assupported in R Markdown. For example, if you want to share a file named data.csv, you make a link to itin your report like this:Here is the data used in my report: [data.csv](data.csv)

    Because output files are versioned along with the rendering of their report, they also benefit from historicalviews. In the example above, if you view a historical rendering of the report, when you click on the data.csvlink, you will get a download of the file from the same point in time as the report.

    5.4.3 Accessing output files over HTTP

    Content deployed to http://connect.mycompany.com/content/42/ will have its output files avail-able under that URL path. An output file named daily-summary.csv will be available at the URLhttp://connect.mycompany.com/content/42/daily-summary.csv.

    The URL for your content is the same as its “Open Solo” location and is available in the RStudio Connectdashboard.

    5.5 Resource Files

    If you want RStudio Connect to host a file that you have in your report’s source directory on your computer,and that file is not generated by the report when you render it, then you will need to mark that file as aresource file. Like an output file, a resource file can be a plot, a data file, or any other artifact that exists asa file. You can use the RStudio IDE to select resource files, or you can list them in the R Markdown header:---title: "Report Title"rmd_output_metadata:

    rsc_output_files:

    25

  • - "data.csv"resource_files:

    - "data.csv"---

    Unlike rsc_output_files, the resource_files key is not nested under rmd_output_metadata. If you donot list your resource files under resource_files, then you will need to add them manually using the “AddMore. . . ” button when deploying from the IDE. See Section 3 for more information on publishing additionalresource files.

    5.6 Email Customization

    5.6.1 Email Subject

    You can customize the subject line used when an email of a report is generated. RStudio Connect uses theoutput metadata entry named rsc_email_subject as email subject. A report without an rsc_email_subjectentry uses its published document name.

    Use the YAML header to specify a simple, static text override of the email subject:---title: "Report Title"rmd_output_metadata:

    rsc_email_subject: "My Email Subject Goes Here"---

    Set the email subject in an R code chunk if you need to dynamically build the subject:changePercent

  • 5.6.2.1 Text Message Bodies

    Use the YAML header to specify a simple, static text override of the email body:---title: "Report Title"rmd_output_metadata:

    rsc_email_body_text: "Here is my custom email message.

    YAML requires a full blank line like the one above to start a new line."---

    The message in the email client would look similar to the following:

    Here is my custom email message.YAML requires a full blank line like the one above to start a new line.

    Set the body text in an R code chunk if you need to dynamically build the message:changePercent

  • body

  • # Create the data structure to hold the embedded image.images

  • The blastula package makes it easy to compose HTML email from R. It can style your message in a waythat renders correctly across a variety of clients, and it can handle many of the details of structuring theHTML and embedding images.

    The following examples require Blastula version 0.2.1 or newer.# Blastula example adapted from https://github.com/rich-iannone/blastula

    library(blastula)library(formattable)

    # Create a data frame.df

  • x ~ icontext(ifelse(x, "ok", "remove"), ifelse(x, "Yes", "No")))

    ))

    # Create the Blastula email object.message

  • You can also embed images and plots in your HTML email.library(blastula)library(ggplot2)

    # Create a ggplot plot object.car_plot

  • New data is available!

    This plot summarizes the new data:

    {add_ggplot(plot_object = car_plot, width = 5, height = 5)}

    Cheers"

    )

    # Give the HTML email data to RStudio Connect.rmarkdown::output_metadata$set(rsc_email_body_html = email$html_str)rmarkdown::output_metadata$set(rsc_email_images = email$images)

    33

  • For consistency, you can always assign both rsc_email_body_html and rsc_email_images at the end ofyour R Markdown report when working with Blastula, even if initially it does not contain embedded images:email

  • See the blastula site at https://github.com/rich-iannone/blastula for more information and examples.

    5.6.3 Email Attachments

    An attachment is an output file that will be attached to an emailed report. You can specify email attachmentfiles in essentially the same way as output files, but instead of listing them under rsc_output_files, youlist them under rsc_email_attachments. For example:---title: "Report Title"rmd_output_metadata:

    rsc_output_files:- "data.csv"

    rsc_email_attachments:- "attachment_1.csv"- "attachment_2.csv"

    ---

    In the example above, we are specifying the file data.csv to be an output file and the files attachment_1.csvand attachment_2.csv to be email attachments.

    It is also possible to specify the list of email attachments from R code. For example:attachments

  • 5.6.5 Suppress Attaching Report To Email

    By default, Connect adds the generated document as an attachment to email messages for that report. You canprevent this attachment from your RMarkdown report by giving the rsc_email_suppress_report_attachmentmetadata property a logical (Boolean) value.

    Use the YAML header to set a default value for rsc_email_suppress_report_attachment. A true valuethat is not later adjusted indicates that the generated content is never to be attached to email.---title: "Report Title"rmd_output_metadata:

    rsc_email_suppress_report_attachment: true---

    You can also make an “attach or not” decision in R code.rmarkdown::output_metadata$set(rsc_email_suppress_report_attachment = TRUE)

    Attachments configured by the rsc_email_attachments metadata property (5.6.3) are stillattached and not affected by the rsc_email_suppress_report_attachment setting.

    6 Shiny

    6.1 User meta-data

    Shiny applications can access the username and groups of the current user through the session parameter ofthe shinyServer function.

    Groups meta-data is populated when using password, or OAuth authentication. It is not populated withLDAP, PAM, or proxy authentication.shinyServer(function(input, output, session) {

    output$username

  • Your Plumber API should use the HTTP_RSTUDIO_CONNECT_CREDENTIALS name to obtain theRStudio-Connect-Credentials header value. All HTTP headers are made available on the reqrequest object using a normalized name prefixed with HTTP_.

    This simple Plumber API defines a /hello route that greets the arriving user.library(jsonlite)library(plumber)

    # Returns a list containing "user" and "groups" information# populated by incoming request data.getUserMetadata

  • 8.2 Recipes

    8.2.1 Detect Whether RStudio Connect Has Your Local R Version

    1. Obtain the server path and API keys from environment variables2. Obtain your local R version using R.version3. Call the “Get R Installation Info” endpoint. See the API Documentation for more information.4. Parse the response using httr::content.5. Check the response for the local R version. If it is not listed, the RStudio Connect server does not

    contain the local R version.# set up environmentconnectServer

  • # now step through the remaining audit logswhile(!is.null(payload$paging[["next"]])) {

    resp