R and Python Basics

Start here

Ten lessons that take you from your first line of code to the libraries analytics runs on. Every example runs inside this page — nothing to install, no sign-up. Each worked example is followed by a Try here box where you type your own code and run it.

TipBefore you start

The first lesson you open takes a few seconds to load the R or Python engine into your browser. The NumPy, pandas and SciPy lessons load the most, so give them a moment on a slow connection.

R Basics

  1. Overview of R and RStudio — what R is, installing it, and the RStudio panels
  2. Data Structures — data types, assignment, vectors, matrices and data frames
  3. Functions — built-in functions and writing your own
  4. Statements and Looping — logical operators, if, and loops

Python Essentials

  1. Understanding Python — why Python for analytics, and how it compares with R
  2. Data Types — numbers, strings, lists, tuples, dictionaries and sets
  3. Operators — assignment, arithmetic, comparison and logical operators
  4. NumPy — arrays, indexing and vectorised maths
  5. pandas — Series, DataFrames, cleaning and summarising data
  6. SciPy — descriptive statistics and statistical tests

These lessons are Module I of Business Analytics for Decision Making, free to read in full.