Curating Your Data Science Content on RStudio Connect

[This article was first published on RStudio | Open source & professional software for data science teams on RStudio, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

RStudio Connect is RStudio’s publishing platform that hosts data science content created in R or Python, such as R Markdown documents, Shiny apps, Jupyter Notebooks, and more.

As you publish to RStudio Connect, you will want your audience to have a great experience looking through your work. Released in July 2021, the connectwidgets package helps create a custom view of your content. Your projects will be easier to organize, distribute, and discover.

The connectwidgets package queries your Connect server to get information about your published content items. It turns them into HTML widget components that can be displayed either in an R Markdown document or Shiny app.

 
Example of gallery created by connectwidgets

The Marketing team at RStudio has several pieces of content published on RStudio’s Connect server. In this blog post, we’ll walk through how we created a project gallery using connectwidgets and R Markdown. View our gallery on colorado.rstudio.com!

Want to see connectwidgets in action? Check out Kelly O’Briant’s webinar, Build Your Ideal Showcase of Data Products.

Interested in trying out connectwidgets but don’t have RStudio Connect? Log into this evaluation environment to get access to a test server.

Curate Projects in R Markdown

Let’s begin by loading the connectwidgets package:

```{r}
install.packages("connectwidgets")
library(connectwidgets)
```

Open up a template by going to File, New File, R Markdown, From Template, and then selecting the connectwidgets(HTML) example.

 
Opening a connectwidgets template

To establish the connection with your RStudio Connect server, add your credentials to your .Renviron file:

CONNECT_SERVER="https://rsc.company.com/"
CONNECT_API_KEY="mysupersecretapikey"

In your R Markdown document, pull in your credential information with the function below:

```{r}
client <- connect(
  # server  = Sys.getenv("CONNECT_SERVER"),
  # api_key = Sys.getenv("CONNECT_API_KEY")
  )
```

The content() function retrieves items from your RStudio Connect server and stores them in a tibble.

```{r}
all_content <- client %>%
  content()
```

You can work with the resulting data frame using your usual R tools. For example, you can select items using built-in helper functions or the dplyr package. In this case, we want to filter the dataset to content by certain users:

```{r}
marketing_content <- all_content %>%
  filter(owner_username %in% c("username1", "username2"))
```

Organize Your Work With HTML Widgets

The package provides organizational components for card, grid, and table views. Each component links to the associated content item in RStudio Connect.

For each chunk, you can select the components that you want to showcase.

Card View

Cards display your content and associated metadata. You can set the image and the description of your project from the RStudio Connect dashboard.

```{r card}
marketing_content %>%
  filter(name == "specific_item_name") %>%
  rsc_card()
```
 
Connectwidgets card view

Grid View

Grids allow you to place content in side-by-side tiles. Similar to cards, you can display certain pieces of metadata.

```{r grid-shiny}
marketing_content %>%
  filter(app_mode == "shiny") %>%
  rsc_grid()
```
 
Connectwidgets grid view

Table View

Would you rather share text? The table component allows you to create a table that shows a fixed set of metadata.

```{r table-plumbertableau}
marketing_content %>%
  filter(stringr::str_detect(name, "seattle_parking")) %>%
  rsc_table()
```
 
Connectwidgets table view

Customize Your Data Science Gallery’s Look

Since connectwidgets is built on R Markdown, you can style your document’s colors and fonts. Here, we use the bslib package to customize our gallery’s appearance:

---
title: "RStudio Marketing Content Gallery"
output:
  html_document:
	theme:
  	bg: "#FFFFFF"
  	fg: "#404040"
  	primary: "#4D8DC9"
  	heading_font:
    	google: "Source Serif Pro"
  	base_font:
    	google: "Source Sans Pro"
  	code_font:
    	google: "JetBrains Mono"
---

Add narrative or additional code chunks to give context to your projects.

Publish to RStudio Connect for Easy Access

Once you’re ready, you can publish your document to RStudio Connect.

 
Publishing to RStudio Connect

RStudio Connect allows you to update the access settings so that you can share your gallery with others. You can also create a custom vanity URL for your work.

Learn More

With RStudio Connect, you can publish your data science projects and also deliver a great experience to your audience.

To leave a comment for the author, please follow the link and comment on their blog: RStudio | Open source & professional software for data science teams on RStudio.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)