Skip to content

Publishing from R#

This section describes how to publish content to Posit Connect from R. This can be done from the RStudio IDE's R Console as an alternative to push-button publishing, or for content types or options that do not support push-button publishing. You can also use this method to publish from R session in a terminal outside of the RStudio IDE.

This workflow uses the rsconnect R package. See the rsconnect documentation or the package help for details.

Shiny Applications#

To publish a Shiny application, use the deployApp function, specifying your project's directory:

rsconnect::deployApp(appDir = '<project-dir>')

For more information:

install.packages('rsconnect')
library(rsconnect)
?rsconnect::deployApp

Plumber APIs#

To get started with publishing Plumber API endpoints, create a directory with a plumber.R file defining your endpoints. From the R console, execute the following, replacing <project-dir> with your project's directory:

rsconnect::deployAPI(api = '<project-dir>')

Quarto Content#

The rsconnect package can deploy all Quarto content supported by Posit Connect (Quarto support is included in version 0.8.26).

To use rsconnect::deployApp() to deploy Quarto content, you need to pass the path to a Quarto binary to function's quarto argument:

rsconnect::deployApp(appDir, quarto = "path/to/quarto")

If Quarto is available on your PATH, you can use "quarto". If this doesn't work, you can use the function quarto_path() from the quarto package:

rsconnect::deployApp(quarto = quarto::quarto_path())

The function rsconnect::writeManifest() can also generate manifests for Quarto content when provided a quarto argument.

Specifying a Target Image#

Note

This section describes a feature that is currently in beta. If you are not sure if this applies to you, please speak with your administrator.

If your Posit Connect installation uses off-host content execution with Kubernetes, Connect will automatically select an appropriate image to use when building or running your content. However, you can also specify a different image if you prefer, by providing the image argument when writing a manifest or deploying:

rsconnect::writeManifest(..., image = "ghcr.io/rstudio/content-base:r4.0.5-py3.8.8-bionic")

rsconnect::deployApp(..., image = "ghcr.io/rstudio/content-base:r4.0.5-py3.8.8-bionic")
rsconnect::deployAPI(..., image = "ghcr.io/rstudio/content-base:r4.0.5-py3.8.8-bionic")
rsconnect::deployDoc(..., image = "ghcr.io/rstudio/content-base:r4.0.5-py3.8.8-bionic")
rsconnect::deploySite(..., image = "ghcr.io/rstudio/content-base:r4.0.5-py3.8.8-bionic")

You may only use an image that has been configured by your administrator. You can see a list of available images by logging in to Posit Connect and clicking the Documentation button at the top of the page.

If the image you select does not contain appropriate R, Python, or Quarto versions for the content you are deploying, the deployment will fail.

At any time, you may redeploy content without specifying an image (or write a manifest without specifying an image, and deploy the manifest) to go back to allowing Posit Connect to choose an image automatically.

Note

Push-button publishing does not support selecting a specific content image at this time.