Skip to content
ImpactMojo ImpactMojo
Browse Membership
Back to Code Studio
Code Studio · Runs in your browser

R & Python for Development

Learn to code from absolute zero, with real R and Python running live in your browser. No installation, works on a modest laptop.

How the live code works. The first time you run R or Python, your browser downloads the language engine once (R about 7 MB, Python about 10 MB; later modules fetch a package or two more). Give the first click 10 to 30 seconds; after that it is quick. A small illustrative household survey is loaded for you as survey.csv (and as SURVEY_CSV).
Module 1 of 8

Your first line of code

Two languages run most development-sector data work: R (loved by statisticians and evaluators) and Python (loved by data scientists). You don't have to choose: this course teaches both, side by side. Click Run, then switch the tab from R to Python and Run again.

A first calculation

Store five people's ages and compute the average. In R a list of numbers is c(...) and the mean is mean(...); in Python it's a list [...] and sum(...) / len(...).

That's 80% of analysis: data goes into a variable, a function does something to it, you read the result.
Module 2 of 8

Data in, data out

Real analysis starts with a dataset: rows (people, households) and columns (variables). We've loaded a small illustrative household-survey sample into SURVEY_CSV for you. Illustrative data

Read it into a data frame: a spreadsheet-like table. In R, read.csv(text = SURVEY_CSV); in Python, pandas. Then peek at the first rows and the shape.

Look at one column

Columns are accessed by name: df$pc_exp in R, df["pc_exp"] in Python. Let's summarise monthly per-capita expenditure.

In the field you'll read NFHS, ASER, PLFS or your own survey the same way: from a .csv file with read.csv("mydata.csv") or pd.read_csv("mydata.csv").
Module 3 of 8

Wrangling: filter and select

Most data work is reshaping: keep some rows, keep some columns. Say we want only rural households. In R (base) we index with a condition; in Python we use pandas.

Add a new column

Flag "low expenditure" households (below ₹1,500/month). Assign a new column and count how many.

Once you're comfortable, R's tidyverse (dplyr) and Python's pandas chaining make this even cleaner: df |> filter(area=="Rural") / df.query('area=="Rural"'). Same idea, nicer grammar. (Our Code Convert Pro tool translates between them.)
Module 4 of 8

Summaries & disaggregation

An average hides as much as it reveals. The real story is in the disaggregation: the same number split by gender, caste, or geography. (This is exactly the lens of the Data Feminism Studio.)

Mean expenditure by gender, then by gender × caste:

Read the gaps. A single "average expenditure" number would erase the gap between, say, General-caste and SC/ST households, and between men and women within each group. Disaggregation is where inequality becomes visible.
Module 5 of 8

Your first chart

A picture makes a gap obvious. We'll draw a bar chart of mean expenditure by caste. In Python we use matplotlib and call show() (a helper we've provided) to display it; in R we use base barplot().

First run of this module downloads the plotting library (a few MB more). The chart appears below the code.
The production-grade tools are R's ggplot2 and Python's matplotlib/seaborn. For design principles, see the Data Visualization 101.
Module 6 of 8

Regression & the idea of impact

A regression asks: as one thing changes, how does another move? Here: does an extra year of education go with higher expenditure? In R, lm(y ~ x); in Python, numpy.polyfit for the same slope.

From correlation to impact

That slope is a correlation, not proof that education causes higher spending. Impact evaluation isolates cause: e.g. difference-in-differences compares the change in a treated group to the change in a comparison group. A tiny illustration: Illustrative

Go deeper in the Causal Inference for Development course and Impact Evaluation 101. A great open text with R/Python/Stata code: Martin Huber, Causal Analysis (MIT Press).
Module 7 of 8

Reproducibility & sharing

Analysis you can't re-run is analysis nobody can trust. The habit: put your steps in a script, comment it, and share the script + data so anyone can reproduce your numbers. Here's the whole pipeline from this course in one runnable cell.

Module 8 of 8

You can now code with data

From "hello" to reading a survey, wrangling it, disaggregating, charting, and running a regression: in both R and Python, entirely in your browser.

RPythontidyverse / pandasWebR + PyodideNo install

Where to go next

→

Econometrics 101

Put the regression to work on real questions.

→

Data Feminism Studio

The ethics and power of disaggregation.

→

Code Convert Pro

Translate your code between R, Python, Stata and SPSS.

→

Sampling Toolkit

Design the survey your code will analyse.