Try R in your browser

Run R without installing anything: edit the code, press Run, see the result

A live R console in the browser (webR) to try the basics of Session 1 before installing R.

This page runs R inside your browser (with webR). Nothing to install, nothing saved: reload the page and everything starts again. The first visit downloads about 10 MB (R itself) and takes a few seconds; prefer Wi-Fi.

Use it to try the basics before Session 1, or if R is not installed yet on your computer. For the course itself, work in RStudio: that is where your project, data and scripts live.

1. R as a calculator

Edit the numbers, then press Run Code.

2. Objects

<- stores a value under a name. Type the name to see the value.

3. Vectors and missing values

A vector holds several values of the same type. NA marks a missing value.

4. A small data frame

A data frame is a table: one row per country, one column per variable.

5. Your turn

Add a column richer_than_china that is TRUE when GDP per capita is above China’s, then print df.

Compare the column with China’s value, the second element: df$gdp_pc_ppp > df$gdp_pc_ppp[2].

df$richer_than_china <- df$gdp_pc_ppp > df$gdp_pc_ppp[2] df
df$richer_than_china <- df$gdp_pc_ppp > df$gdp_pc_ppp[2]
df

Source of the values: World Bank, World Development Indicators (WDI), 2022, as in the course data. Gini: latest year available (2023); the China value (36.0 in 2022) is left out on purpose to show NA.

Back to top