STAT 133
  1. Tools
  2. Positron
  • Home
  • Syllabus
  • Office Hours

  • Tools
    • DataHub
    • Shell
    • R
    • R App
    • Git
    • Positron

  • Projects
    • Sampson’s Monks
    • Zero Emission Vehicles
    • Your Life in Data

  • Problem Sets
    • PS 1
    • PS 2
    • PS 3
    • PS 4
  1. Tools
  2. Positron

Positron

Positron logo

Positron is the code editor (IDE) we use to write and run R and Quarto. It is built by Posit, the same company behind RStudio, and is designed for data science.

Installing Positron

  1. Go to https://positron.posit.co.
  2. Download the installer for your operating system.
  3. Run the installer and open Positron.

Make sure you already have R installed so Positron can find it. If your computer is too old to run Positron, don’t fret. You can log into DataHub and work with Positron there.

The layout

  • Editor: where you write scripts and .qmd documents.
  • Console: a live R session for running code interactively.
  • Variables / Environment: shows the objects currently in memory.
  • Plots, Help, and a Terminal are available in the side panes.

Opening a folder from a GitHub repository

Most of the projects in this course start by copying (“cloning”) a repository from GitHub onto your computer and opening it as a Positron folder.

  1. On GitHub, open the repository and click the green Code button. Copy the HTTPS URL, which ends in .git.
  2. In Positron, click the button in the upper left corner for New > New Folder from Git, then paste the URL in the top box.
  3. Choose a folder on your computer to put the repository in — somewhere you’ll find again, like Documents/stat133/. Positron creates a new subfolder named after the repository.
  4. Click OK.

The first time you clone, Git may ask for your GitHub username and a personal access token; see Git and GitHub for how to set that up.

Knowing which folder you’re in

Positron always has exactly one folder open, and everything — the console’s working directory, the file paths in your code, which repository git commands act on — is relative to that folder.

Check which one it is in the top-right corner of the window, next to the interpreter selector: it shows the name of the open folder alongside the running R session. You can also confirm from the console:

getwd()

If that isn’t the folder you expect, use File → Open Folder to switch. Opening a file from another project does not change the open folder.

Running code

  • Put your cursor on a line and press ⌘ + Return (macOS) or Ctrl + Enter (Windows) to run it in the console.
  • Open a .qmd file and click Render to preview a Quarto document.

Tips

  • Use the built-in Terminal pane to run shell and Git commands without leaving the editor.
 
  • License