stat545ubc-2020 / collaborative-helium

collaborative-helium created by GitHub Classroom
0 stars 0 forks source link

Tb2 #14

Closed Tomiyosi-Bola closed 4 years ago

Tomiyosi-Bola commented 4 years ago

These are the corrections made exercise 6 Before

### ERROR HERE ###
movieLens %>%
  tally(year, sort = TRUE)

After

movieLens %>%
  count(year)

Before

movieLens %>%
  count(c(title, rating), sort = TRUE)

After

movieLens %>%
  count(title, rating)

Before

movieLens %>%
  add_count(title) %>%
  n <= 5 %>%
  mutate(n_reviews = n)

After

movieLens %>%
  add_count(title, name = 'n') %>%
filter(n <= 5) %>%
mutate(n_reviews = n)
berudri commented 4 years ago

Three codes were corrected for exercise 6. They are as follows:

  1. In the second code: Since we want to find the number of movie reviews by year, we use the count function on the column year. This groups the rows by year and counts the unique values (in this case, movies).
  2. We removed sort = TRUE as it is not required.
  3. In the fourth code: we use add_count() as it counts group-wise and adds a new column. We named the new column 'n' in our code by adding name = 'n' as an argument for add_count(). Next, we want to filter the movies that have 5 reviews or under. So we added the filter function.