Explore the 1985 Cars Dataset Task 9

I keep getting the following error code on Task 9

filter rows

cars %>%
mpg_exceeds_threshold ← filter(mpg_diff_from_threshold > 0)
Error in filter(mpg_diff_from_threshold > 0): object ‘mpg_diff_from_threshold’ not found
Hide
mpg_exceeds_threshold
Error in eval(expr, envir, enclos): object ‘mpg_exceeds_threshold’ not found

Can someone look over what I am doing wrong?


title: “1985 Cars”

output: html-notebook


Task 1


# load libraries

library("readr")

library("dplyr")

Task 2


# load data

cars <- read.csv(file = 'cars85.csv')

Task 3


# inspect data

head(cars)

summary(cars)

Task 4


# select columns

cars <- cars %>%

   select(-normalized_losses)

Task 5


# view columns

cars

Task 6


# rename column

cars %>%

  rename(risk_factor = symboling)

Task 7


# define threshold

mpg_threshold <- 30

Task 8


# add column

cars %>%

  mutate(mpg_diff_from_threshold = highway_mpg - mpg_threshold)

Task 9


# filter rows

cars %>%

 mpg_exceeds_threshold <- filter(mpg_diff_from_threshold > 0)

mpg_exceeds_threshold


Thanks

Tried adding a head() statement and got this error on number 8

# add column
 cars %>%
  mutate(mpg_diff_from_threshold = highway_mpg - mpg_threshold)
head(mpg_diff_from_threshold)
Error in head(mpg_diff_from_threshold): object 'mpg_diff_from_threshold' not found

in task 8 you havent saved the data frame; thats why the fallowing tasks will be wrong
it should be like this
cars ← cars # here was mistake %>% mutate(mpg_diff_from_threshold = highway_mpg - mpg_threshold)

the for task 9 I am not sure if it valid for saving, try
mpg_exceeds_threshold ← cars %>% filter(mpg_diff_from_threshold > 0)