Table of Contents

Using the RStudio Starter Pack

Brock Schmutzler Updated by Brock Schmutzler

RStudio is an integrated development environment (built by Posit) that eCornell uses for many courses with coding projects in R. Specifically, eCornell uses an open-source version of RStudio Server hosted by Codio and installed via the Tools > Install Software utility (available from the Codio menu within each Codio unit).

Creating Codio Assignments

The easiest way to create a Codio assignment with an RStudio environment is to use eCornell's RStudio Starter Pack because it has "starter files" pre-loaded in Codio's workspace, in addition to running eCornell's JupyterLab and RStudio stack called Ubuntu 22.04 + JupyterLab + RStudio (built from the Codio-certified JupyterLab stack for Ubuntu 22.04 LTS). The JupyterLab and RStudio stack includes several Python packages (e.g., numpy, pandas, seaborn) and R packages (e.g., ggplot2, tidyverse) that are commonly used for data science projects. The RStudio Starter Pack files are stored in /home/codio/workspace, whereas the JupyterLab and RStudio stack is saved at the /home/codio level.

As its name suggests, the Ubuntu 22.04 + JupyterLab + RStudio stack also has JupyterLab installed. For help with JupyterLab, see Using the JupyterLab Starter Pack.

To use eCornell's RStudio Starter Pack, add a new Codio assignment by following these steps:

  1. Select Add assignment > New
    Add new Codio assignment
  2. Select the Starter Pack option as your starting point and then click browse
    Select "Starter Pack" as your starting point
  3. Search All starter packs for "RStudio Starter Pack"
    Search for and select "RStudio Starter Pack"
  4. Change your assignment name appropriately and then click Create
    Create assignment with RStudio Starter Pack

Adding R Markdown Files

After creating a new assignment (or opening an assignment that has already been created), you will be taken to a screen that looks something like this:

Initial RStudio window

To add the contents of an R Markdown file for the Codio assignment:

  1. Copy and paste the contents of your R Markdown file into the Untitled1.Rmd file in the source panel:
    Copy and paste contents of your .Rmd file
  2. Click File > Save in the RStudio menu
    Go to File > Save in the RStudio menu
  3. Give your R Markdown file an appropriate name (e.g., Demo_Assignment.Rmd) and click Save
    Name your .Rmd file and click Save
    Your new .Rmd file will now appear in the Files tab of the lower-right panel
  4. Select Education > Publish Assignment from the Codio menu, write a descriptive note in the CHANGELOG, and click PUBLISH. When you see that the publish was successful, click RETURN TO DASHBOARD.
    Select Education > Publish Assignment
    Write a descriptive note in the CHANGELOG
    Successful initial publish
If you follow the above steps using the RStudio Starter Pack to publish a Codio unit, then please continue reading the next section on Creating New Stacks because at this stage you will still be running the Ubuntu 22.04 + JupyterLab + RStudio stack that comes with the RStudio Starter Pack.

Creating New Stacks

When you create an assignment using the RStudio Starter Pack, the assignment comes with an underlying stack called Ubuntu 22.04 + JupyterLab + RStudio. Since each series of courses should have its own stack, it is important to create a new stack for your courses by following the steps below. Before reading the steps below, please take heed of the following warning:

DO NOT create a new version of the Ubuntu 22.04 + JupyterLab + RStudio stack because that new version would be used by future assignments created from the RStudio Starter Pack. If you believe the Ubuntu 22.04 + JupyterLab + RStudio stack should be updated, contact a member of the Instructional Technologies Group (ITG) for assistance.
  1. Go to Project > Stack > Create New...
    Go to Project > Stack > Create New...
  2. Make sure New Stack is selected, give your stack a name that matches the series of courses (e.g., DEMO120s Stack), select Public, and make eCornell the owner
    Make sure "New Stack", "Public", and "eCornell" are selected
  3. Click CREATE and click YES when prompted with the CHANGE STACK CONFIRMATION dialog box. After clicking YES, you should see a message saying Stack build in progress. If you receive a strange error message, click CREATE again and the stack build should begin this time.
    Select "YES" at the "CHANGE STACK CONFIRMATION" prompt
    New stack for RStudio is building
  4. After your stack has been created, go to Project > Stack > Settings... to make sure the assignment is using the new stack you created. If your new stack is the CURRENT STACK for your assignment, proceed to step 6. If the CURRENT STACK for your assignment is still Ubuntu 22.04 + JupyterLab + RStudio, complete step 5 before going to step 6.
    Project > Stack > Settings...
  5. If the CURRENT STACK for your assignment is not the new stack you created, make sure you change the CURRENT STACK to your new stack before installing or updating any software. After changing the CURRENT STACK to your newly created stack, proceed to step 6.
    1. Click the drop-down menu to search for your new stack
      Check the stack settings
    2. Search for your new stack (e.g., DEMO120s Stack)
      Search for your new stack
    3. Select your new stack (e.g., DEMO120s Stack) and click SAVE
      Save your new stack
    4. Confirm the stack change by entering the confirmation code in the CHANGE STACK CONFIRMATION dialog box and reload your browser after you receive a message saying Stack updated successfully
      Select "YES" to confirm the change to your new stack
      Stack updated successfully
  6. Update and/or install software on your new stack and then create a new version by going to Project > Stack > Create New... and selecting New Stack Version. Make sure to write a concise and descriptive CHANGELOG entry.
    Create new version of stack
  7. Go to Project > Stack > Settings... to confirm that a new stack version has been created and make sure that VERSION is set to Use the latest version
    Check that your assignment is using the latest version of your stack
  8. Publish your assignment with the new stack version and write a concise and descriptive CHANGELOG entry. It may take a few minutes for the publishing process to complete and return a SUCCESSFUL message.
    Publish your assignment with new stack version
    Successful publish after changing to new stack version

Configuring Workspace Starter Files

The starter files in /home/codio/workspace are:

  • .guides/load.js
  • .guides/styles.css
  • .codio
  • .codio-menu
  • .settings

For most use-cases, you will not need to modify any of these files. However, if you need modified versions for a specific course, high-level instructions are provided in the subsections below. When in doubt, please contact a member of the Instructional Technologies Group (ITG) for assistance.

.guides/load.js

The file .guides/load.js is a script that pulls guide text from AWS S3. It looks like this:

$("#guide").load("https://ecornell.s3.amazonaws.com/Codio/Reuseables/RStudio/guideText.txt");

If you need to modify the text on the collapsable Guide page, copy the text file guideText.txt from the S3 folder Codio/Reusables/RStudio and put a modified version in a folder on S3 that is specific to your series of courses and replace the link in load.js — e.g.,

$("#guide").load("https://ecornell.s3.amazonaws.com/Codio/Courses/DEMO120s/guideText.txt");

DO NOT modify the guideText.txt file in the S3 folder Codio/Reusables/RStudio because those changes will propagate to ALL courses whose guide text is linked to that file. The only people allowed to modify Codio/Reuseables/RStudio/guideText.txt are members of the Instructional Technologies Group (ITG). Please contact ITG if you find a typo or believe the text should be changed.

.guides/styles.css

The file .guides/styles.css imports a CSS stylesheet from S3:

@import "https://ecornell.s3.amazonaws.com/Codio/CSS/styles.css";

The stylesheet Codio/CSS/styles.css controls the look of HTML elements in the Codio guide and is common to most Codio units developed by eCornell.

DO NOT modify the styles.css file in the S3 folder Codio/CSS because those changes will propagate to ALL courses linked to that file. In the unlikely scenario that you need to include additional styling elements, you can add them below the import statement in the .guides/styles.css file for your course-specific Codio units.
.codio

The .codio file contains code that configures the RStudio preview button that appears in the Codio menu bar across the top of your screen:

Configuration of .codio file for RStudio preview button

As shown in the image above, the contents of .codio look like this:

{
// Preview button configuration
"preview": {
"RStudio": "https://{{domain8787}}"
}
}

Clicking the RStudio preview button opens an instance of RStudio while you are in Edit mode:

RStudio preview in Edit mode

Note that this RStudio preview tab in Edit mode is the same as what you see when you are in Preview mode (i.e., when you click the Preview button in the upper-right corner of the Guide Editor tab):

Preview button in upper-right corner of Guide Editor

Preview mode shows you what the Codio unit will look like when it is embedded in Canvas.

.codio-menu

The .codio-menu file controls which menu options are shown to students in Canvas:

{
"Logo": false,
"Codio": false,
"Project": {
"Restart Box...": true,
"Resync File Tree": false,
"Export as Zip": false,
"Settings...": false,
"Stack": false,
"Permissions...": false,
"Box Info": false,
"Reset Box...": false,
"Create Copy...": false,
"Share...": false,
"QR Code for Preview URL": false,
"Delete...": false,
"Exit": false
},
"File": false,
"Edit": false,
"Find": false,
"View": false,
"Tools": false,
"Education": {
"Mark as Completed": true,
"Code Comments": false,
"Earsketch": false,
"Jupyter Lab": false
},
"Help": false,
"Run": false,
"Debugger": false,
"Status": false,
"Preview": false,
"Toggle sections list": false,
"Online": false
}

The configuration that comes with the RStudio Starter Pack only shows the options Project > Restart Box... and Education > Mark as Completed in the top Codio menu bar. This is typically all that is needed for a Codio unit using RStudio because all student work is done within the RStudio environment.

Project > Restart Box... allows students to restart their Codio box without losing their saved work. This is useful when RStudio becomes unresponsive. After restarting, students will need to reload their browser.

If no auto-grading is necessary and facilitators will not be reviewing the work (e.g., in an ungraded practice activity), you can disable the Education > Mark as Completed button in the ASSIGNMENT settings (Overview > Settings) by toggling on the option DISABLE MARK AS COMPLETED (make sure to click the Save Changes button afterwards):

Assignment settings for an ungraded Codio unit
Disabling the Education > Mark as Completed button causes it to appear "grayed out" to indicate that it cannot be selected. All graded assignments should have the MARK AS COMPLETED button enabled.

If you need to expose more Codio menu options to students, you can follow these steps:

  1. Copy Codio/Reuseables/RStudio/guideText.txt
  2. Add codio-menu.txt to a course-specific S3 folder (e.g., /Codio/Courses/DEMO120s)
  3. Modify the content of your course-specific codio-menu.txt file as needed
  4. Modify the file /home/codio/startup.sh as directed in How to Centralize the .codio-menu to One Location (steps 3b, 4b, and 5)
  5. Create a new course-specific stack version (DO NOT create a new version of Ubuntu 22.04 + JupyterLab + RStudio)

For example, here is a .codio-menu.txt file that would also expose the Project > Export as Zip menu option:

{
"Logo": false,
"Codio": false,
"Project": {
"Restart Box...": true,
"Resync File Tree": false,
"Export as Zip": true,
"Settings...": false,
"Stack": false,
"Permissions...": false,
"Box Info": false,
"Reset Box...": false,
"Create Copy...": false,
"Share...": false,
"QR Code for Preview URL": false,
"Delete...": false,
"Exit": false
},
"File": false,
"Edit": false,
"Find": false,
"View": false,
"Tools": false,
"Education": {
"Mark as Completed": true,
"Code Comments": false,
"Earsketch": false,
"Jupyter Lab": false
},
"Help": false,
"Run": false,
"Debugger": false,
"Status": false,
"Preview": false,
"Toggle sections list": false,
"Online": false
}

Project > Export to Zip gives students the ability to export all their workspace files to a ZIP file.
.settings

The .settings file controls the text editor settings of the Guide Editor. This file is automatically generated by Codio when the Guide is created — you will not need to make any changes to the .settings file.

Graded Canvas Assignments

Follow the steps in this section to set up a graded assignment in Canvas with an embedded Codio unit.

  1. Create a new Canvas assignment page
    Create new Canvas assignment
  2. Configure assignment settings
    1. Use External Tool submission
    2. Create Codio Projects group
    3. Display grade as Percentage
      Canvas assignment external tool submissioin
  3. Configure Codio assignment settings (make sure to Save Changes for each setting)
    1. Read Only with Resubmit
      Read Only with Resubmit
    2. TEACHERS GRADING (toggle off if the assignment is not graded)
      Teachers Grading
  4. Test in Student View
    1. Enter any solution code and run all cells to make sure no errors or warnings are raised
      Enter solution code and run all cells
    2. Save your changes by pressing command+S
    3. Go to the Education menu and select Mark as Completed
      Select "Mark as Completed" from the "Education" menu
      Codio begins marking the assignment as completed
      Successfully marked as completed
  5. Grade the Test Student submission (in teacher view after leaving Test Student view)
    1. Find the Test Student submission, click the three vertical dots icon, and select Open the project
      Open the submitted Test Student project
    2. Click the WRITABLE COPY (sic) button in the upper-right corner of the opened project
      Click the "Writable Copy" button in the upper right
    3. Click the GRADING button in the upper-right corner of the writeable copy
      Click the "Grading" button in upper right of the writeable copy
    4. Click the Add Grade button in the GRADE COMPONENTS section
      Click the "Add Grade" button
    5. Enter the grade as a percentage and click Done (see the next step if you are using a rubric)
      Enter student grade
    6. If you are using a rubric, select rubric boxes, click APPLY, and then click Done
      Enter student grade using a rubric

Ungraded Canvas Assignments

Follow the steps in this section to set up an ungraded assignment in Canvas with an embedded Codio unit.

  1. Create a new Canvas page (e.g., Code: Demo Activity)
    Create new Canvas page
  2. Edit your new page by going to the plug-in menu and selecting Codio
  3. Select the Codio unit you want to embed in the Canvas page (e.g., Demo Activity)
    Select the appropriate Codio unit
  4. Go to HTML view and make sure the width is 100% and height is 800px, and then click Save
    Make sure width is 100% and height is 800px
  5. Go to the Codio unit Settings and make sure grading (teachers, assessments, script) is turned off. If not, toggle them all off and click Save Changes.
    Make sure all grading is turned off

Quick Tips

This section contains a few quick tips on how to keep your R Markdown files easy to read.

Loading Packages
To suppress any unnecessary (and perhaps distracting) package startup messages, you can use the R code |> suppressPackageStartupMessages() after the library(package) command. This will avoid any potential student confusion regarding confusing, yet benign, package startup messages.
Use "|> suppressPackageStartupMessages()"
Rerun code with "|> suppressPackageStartupMessages()"
Formatting R Code

To quickly format the R code in an open R Markdown file, select Style active file from the Addins drop-down menu. Doing this will use use the styler package to format the R code according to the tidyverse style guide.

You can use the magic comments # style: off and # style: on to make styler skip over certain lines of R code, as described in the documentation on ignoring certain lines. You can also control the level of invasiveness by selecting Addins > Set style and set various configuration options (e.g., number of spaces to indent).
Select "Style active file" from the "Addins" drop-down menu
R code properly formatted
Duplicating Assignments

After you have created one Codio assignment using the RStudio Starter Pack, sometimes the easiest way to create more Codio assignments is to duplicate the first one. The following steps walk through this process.

  1. Click the Duplicate button (copy icon) for the assignment you want to copy (e.g., Demo Assignment)
    Click the Duplicate button for the assignment you want to copy
  2. Name the copy something different from the original and click Duplicate
    Rename the copy and click the Duplicate button
  3. Open the duplicated assignment (e.g., Second Demo Assignment)
    Open the duplicated assignment
  4. Right-click the name of the R Markdown file to rename it (e.g., Second_Demo_Assignment.Rmd)
    Rename the R Markdown file in the duplicated assignment
    Click the OK button to rename the R Markdown file
  5. Save changes to the renamed R Markdown file (click the disk icon, press command+S, or select File > Save)
    Save changes by clicking the disk icon
    Save changes by selecting File > Save
  6. Expand the right sidebar guide and click the Edit button in the upper-right corner
    Expand collapsed guide page to enter Edit mode
  7. Delete the old assignment folder from .R.proj.user/shared/notebooks and then publish
    Delete old notebook and publish the new assignment
    Initial publish of duplicated assignment

How did we do?

Using Code Formatters

Conda Environments in Codio

Contact