R: Guided Project: NYC Schools Perceptions error object 'variable' not found


I’m now doing the Guided Project NYC Schools Perceptions. I conducted the same steps provided in the course but now I get an error that the object ‘variable’ is not found. In the course the code worked.

Screen Link: https://app.dataquest.io/m/327/guided-project%3A-nyc-schools-perceptions/6/look-for-interesting-correlations-and-examine-relationships-using-scatter-plots

My Code:

cor_mat <- combined %>% 
  select_if(is.numeric) %>%
  cor(use = "pairwise.complete.obs")

cor_tib <- cor_mat %>%
  as_tibble(rownames = "variable")

sat_cors <- cor_tib %>%
  select(variable, avg_sat_score) %>%
  filter(avg_sat_score > 0.25 | avg_sat_score < -0.25)

What I expected to happen:

  • Select the columns that contain relationships between all variables paired with avg_sat_score and the names of the variables.
  • Filter the selected columns to retain only rows with correlation coefficient values greater than 0.25 or less than -0.25.

What actually happened:

Error in FUN(X[[i]], ...) : object 'variable' not found

I hope you can help me with this error! Thanks in advance!

1 Like

Hi!! I did like this, I select only the SATs average and the columns with the survey scores.

cor_mat <- dataframe_schools_survey %>%
  select(avg_sat_score, saf_p_11:aca_tot_11) %>% 
  cor(use = "pairwise.complete.obs")

the rest I did the same as you.