R, Answer right, but code returns unexpected results

Hi R people,
I’m in the Aggregates in R lesson, specifically in the Combining Grouping w Filter here:

https://www.codecademy.com/courses/learn-r/lessons/r-aggregates/exercises/grouped-filters?action=resume_content_item

In this step, I’m looking for the most popular shoe types for company Shoefly.com. I type this:

# define most_pop_orders here:
most_pop_orders <- orders %>%
group_by(shoe_type) %>%
filter(n() > 16)
most_pop_orders

Lesson says I’m right, but I get a return in the html with all the columns, not just column shoe_type. What gives?

Thanks!

It should be returning all the columns! Let’s go through this line by line:

most_pop_orders <- orders %>%

This line names the output of the whole chunk most_pop_orders, and pipes the orders dataframe into the subsequent code.

group_by(shoe_type) %>%

This line groups rows in the orders dataframe based on shoe_type, and pipes the result into the subsequent code.

filter(n() > 16)

This line filters the rows (now grouped by shoe_type) to retrieve rows with count more than 16.

As shown, no where in this code selects specific columns to show. To do so, we would need to use the select() clause. A simple example of this:

most_pop_orders <- orders %>%
  group_by(shoe_type) %>%
  filter(n() > 16)
  select(shoe_type)
  most_pop_orders

Hope this helps!