Data Frames in R

Interactive R tutorial on data frames: build a table, pull out columns, filter rows and explore R’s built-in datasets — running live in your browser.

A data frame is R’s version of a spreadsheet: named columns, each a vector of the same length. This is how real data lives in R. Run each box and experiment.

Build a data frame

Look at a column with $

Explore a built-in dataset

R ships with datasets you can use immediately. mtcars describes 32 cars:

Filter rows by a condition

Read this as “rows where mpg is above 25, all columns”:

The comma matters: [rows, columns]. Leaving the columns side blank keeps them all.

A quick grouped summary

Average mpg for automatic (0) vs manual (1) cars:

Your turn

iris is another famous dataset (flower measurements). Explore it:


Next: Your first plot → — turning data into pictures.