R & Python for Development
A South Asia 101 — learn to code from absolute zero, with real R and Python running live in your browser. No installation, works on a modest laptop.
SURVEY_CSV) is loaded for you when the engine starts, so every code cell can use it.
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(...).
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.
.csv file with read.csv("mydata.csv") or pd.read_csv("mydata.csv").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.
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.)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 Lab.)
Mean expenditure by gender, then by gender × caste:
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().
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
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.
- Comment every step (the
#lines) so future-you understands it. - Never edit data by hand — every change should be a line of code you can re-run.
- Share the script and data (a folder, a GitHub repo, an
.Rproj/ notebook). Reproducibility is the difference between a claim and evidence.
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.
Where to go next
Econometrics 101
Put the regression to work on real questions.
Data Feminism Lab
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.