Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

L02 — Installing R & RStudio; the CSUB JupyterHub

R Help for Beginners

1Objectives

By the end of this lesson you will be able to:

  1. Choose between installing R + RStudio locally and using the CSUB JupyterHub, based on your own device and needs.

  2. Install R, RStudio, and this book’s packages on your own computer.

  3. Access the CSUB JupyterHub and open a notebook with R already running.

  4. Compare the two options and know when to use each.

2Two ways to run R

You do not have to choose only one. Most people end up using both at different points in a term.

Install locally (R + RStudio)CSUB JupyterHub
Setup requiredInstall two programs, onceNone — a web browser is enough
Works offlineYesNo — needs internet
Works on a shared/lab/library computerOnly if you can install softwareYes
Where your work is savedYour own computerThe JupyterHub server (csub.jupyter.cal-icor.org)
Good forHomework at home, projects, keeping R long-termLabs, quick checks, any device without admin rights
This book’s packages (mosaic, BSDA)You install once (below)Pre-installed for you

3Option A — Install R and RStudio on your own computer

R and RStudio are two separate, both free, downloads. R is the language and engine that actually runs your code; RStudio is an application (an “IDE,” integrated development environment) that makes working in R much more comfortable — it adds a code editor, a place to see your data and plots, and menus for common tasks. You need both; RStudio does nothing without R installed underneath it.

Step 1 — Install R. Go to the Comprehensive R Archive Network (CRAN) at cran.r-project.org and choose the installer for your operating system (Windows, macOS, or Linux). Run the installer with the default options. This book is built and tested on R 4.5.2 — any recent 4.x release will work, but if you can choose, prefer the newest stable release CRAN offers.

Step 2 — Install RStudio Desktop. Go to posit.co/download/rstudio-desktop and download the free RStudio Desktop edition for your operating system. Run the installer with the default options. RStudio will automatically find the R installation from Step 1 — you do not need to point it anywhere.

Step 3 — Open RStudio and install the course packages. Open RStudio (not R by itself). In the Console pane (usually bottom-left), type the following and press Enter:

install.packages(c("mosaic", "BSDA"))

This single line downloads and installs both packages this book uses — mosaic (with its ggformula plotting layer, plus dplyr and other helpers it pulls in automatically) and BSDA — from CRAN. It can take a minute or two the first time; you’ll see download and compilation messages scroll by, and it’s done when you get your prompt (>) back with no red Error text. You only need to run install.packages() once per computer — after that, L05 shows you the much shorter library() line you run at the start of every session.

4Option B — The CSUB JupyterHub (nothing to install)

CSUB provides a hosted, browser-based platform — JupyterHub — where R, mosaic, BSDA, and every other package this book needs are already installed for you. You open a web browser, sign in, and start writing R immediately. Nothing below requires you to have ever used R, Jupyter, or a command line before.

Step 1 — Go to the JupyterHub URL. Open https://csub.jupyter.cal-icor.org/ in any web browser, on any device (a lab computer, your own laptop, even a tablet). Someone sharing a course with you — a syllabus, a lab handout — may also give you a link that pre-loads a specific week’s materials; that link still starts at this same sign-in page.

Step 2 — Sign in with your CSUB credentials. Use the same campus username and password you already use for email and MyCSUB. This is your existing CSUB account — there is no separate sign-up and nothing new to create. If your credentials don’t work here, they’re almost certainly the same account issue you’d hit signing in to email or MyCSUB, so that’s the right place to get it fixed (campus IT / help desk).

Step 3 — Wait for your server to start, then look at the launcher. The first time you sign in during a session, the Hub spends a few seconds “starting your server” — a private workspace made just for you. Once it’s ready you land on the launcher: a screen of tiles, each one a way to start something new. This screen is standard JupyterLab (the software the Hub runs), so on any deployment you should see a Notebook section with a tile labeled R (its icon is the blue-and-grey R logo used everywhere R runs inside Jupyter), and usually an R console tile nearby too — the exact layout and theme can vary a little by deployment, but those two tiles are what you’re looking for. A notebook mixes writing and code in one document (Step 4 below and all of L03 are about this); a console is a bare, line-by-line place to type R with no document around it. As a beginner, start with a notebook: click the R tile under Notebook, and a new, mostly-empty notebook opens with one empty box waiting for you.

Step 4 — Type a line of R and run it. Click into that empty box (a cell) and type a line of R, for example:

2 + 2

Press Shift+Enter — this runs the cell and moves you to the next one. The result appears directly underneath the cell, in the notebook itself:

[1] 4

That’s it — you just ran R in your browser with nothing installed. Ctrl+Enter runs a cell without moving to the next one, if you want to rerun something in place. L03 covers notebooks — cells, order of execution, saving — in full depth.

Step 5 — Load this book’s packages: nothing to install, just library(). Unlike a fresh local install (Option A), the JupyterHub already has mosaic and BSDA installed system-wide for every CSUB user. You never run install.packages() here — just load them, in a new cell, every time you start a fresh notebook:

library(mosaic)
library(BSDA)

Running that produces a block of messages about “masked” functions — that is normal, expected output, not an error (L05 explains exactly what it means and shows the full message). As long as you don’t see red Error text, both packages are ready to use.

5Which one should you use?

There is no wrong choice — many people switch between them:

Either way, the R code you write is identical — mosaic and BSDA behave the same whether you’re in RStudio or a JupyterHub notebook. L03 walks through the actual working environment (panes, cells, projects) for both.

6Summary