7. Challenge Cleaning our dataset in Advance Regular Expressions

Stuck on this code

Screen Link:

My Code:


pattern  <-  "(?i)(\\w+SQL)"
hn_sql <-  hn %>% 
    filter(str_detect(title, pattern)) %>%
    mutate(flavor = str_match(title, pattern)[,2]) %>%
    mutate(flavor = str_to_lower(flavor))

hn_sql_flavor_avg <- hn_sql %>%
    select(flavor, num_comments) %>%
    group_by(flavor) %>%
    summarise(avg = mean(num_comments))

What I expected to happen:
I expect it to create a data frame hn_sql that filters titles from the hn dataset which includes the designated pattern and then create a column for flavor and convert the titles to lowercase.

What actually happened:
I am getting a message that my code caused an error and the data frame returned by that section is different than expected.

∑marise() ungrouping output (override with .groups argument)

This is my first time ever posting, so please let me know if I haven’t formatted it correctly. I can’t figure out what I am overlooking here…

1 Like

It seems that your code is correct. The error you are getting is a normal, expected warning given when using summarise() after group_by(). Always google warning messages :wink:

I think that the screen has a bug, so that the code must match the answer key format exactly for it to be approved. So if you see that your code indeed is correct, you can copy-paste the answer into the script, and proceed. After reporting the potential bug, of course.

1 Like

Thank you @anstho, for creating a ticket for this, I have logged this issue.

@mlhenry292 I would suggest you to use the following workaround to mark the screen as complete: