BLACK FRIDAY EXTRA SAVINGS EVENT - EXTENDED
START FREE

Unexpected error in mission 402-5

, ,

I don’t know what I am doing wrong here. Please help! I am stuck here in the course.

Screen Link: https://app.dataquest.io/m/402/working-with-missing-data/5/preparing-data-for-missing-data-visualization

Mission:
We have provided the mvc_na dataframe. dplyr package is available from previous screens.

  1. Use the pivot_longer() function, from the tidyr package, to transform mvc_na dataframe into a new dataframe containing x and value variables.
  • Use the function everything() to indicate that all columns are involved.
  1. Create a new column y containing the row numbers.
  2. Assign the result to mvc_na_heat .
    My Code:
    library(purrr)
    library(tidyr)

mvc_na <- map_df(mvc, function(x) as.numeric(is.na(x)))
library(tidyr)

mvc_na_heat <- mvc_na >
pivot_longer(cols = everything(),
names_to = “x”) >
group_by(x) >
mutate(y = row_number())

Error:
Error in eval(expr, envir, enclos): object 'x' not found
Traceback:

Other details:
When I run it there is no error but when I submit it there is error.

Hello @amrutha.killada306. The code you provided worked for me (assuming that you actually used the correct pipe operator %>% instead of the > shown above). To pass this screen, I’d suggest running your code, or running the answer code, but add a # comment in the first line of code. This will clear the cache and evaluate the “new” code in the editor. For example, doing this with the answer code looks like this:

# this comment will clear your cache
library(purrr)

mvc_na <- map_df(mvc, function(x) as.numeric(is.na(x)))
library(tidyr)
                 
mvc_na_heat <- mvc_na %>%
    pivot_longer(cols = everything(),
               names_to = "x") %>%
    group_by(x) %>%
    mutate(y = row_number())

I hope this helps! Please let me know if you have any issues. Best,
-Casey