Track a data frame's shape through several steps

A ride-share analyst runs the R code below on trip records for six drivers.


R
trips <- data.frame(
  driver = c("A", "B", "C", "D", "E", "F"),
  km = c(12, 40, 7, 33, 18, 52),
  fare = c(15, 46, 10, 39, 22, 60)
)
trips[, "per_km"] <- trips[, "fare"] / trips[, "km"]
long <- trips[trips[, "km"] > 15, c("driver", "per_km")]


After the code runs, give each of the following as a whole number: the number of columns in trips, the number of rows in long, and the number of columns in long.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More R Data Frames Questions: