Tsallaka zuwa abun ciki
Justice Tech School

Subsetting Data Frames

Use rows, columns and conditions with [ , ] or subset().

Example
df <- data.frame(name = c("Ada", "Kofi", "Amina"), score = c(92, 78, 85))
print(df[df$score > 80, ])
print(subset(df, score < 90, select = name))
print(df[order(-df$score), ])
print(df[["name"]])

Exercise

Filter rows.

df[df$score  80, ]

Quiz Test

What does the empty part after the comma mean?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.