Can anyone help explain what these codes mean? What are the problems here?

df$num_as <- df$country %>%
  str_count("a")

df %>% filter(num_as == max(num_as))

Error in filter(): ! Problem while computing ..1 = num_as == max(num_as). Caused by error in mask$eval_all_filter(): ! object 'num_as' not found Backtrace: 1. df %>% filter(num_as == max(num_as)) 3. dplyr:::filter.data.frame(., num_as == max(num_as)) 4. dplyr:::filter_rows(.data, ..., caller_env = caller_env()) 5. dplyr:::filter_eval(dots, mask = mask, error_call = error_call) 7. mask$eval_all_filter(dots, env_filter)

[image] Show Traceback

Error in filter(., num_as == max(num_as)) : Caused by error in mask$eval_all_filter(): ! object 'num_as' not found

Confirm that this did work to create the variable.

Still don't understand.

To this point, what are the variables in df.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.