A/B Testing for ShoeFly.com - mutate(percentage = count/sum(count)) R

A/B Testing for ShoeFly.com - Step 4

https://www.codecademy.com/courses/learn-r/projects/r-aggregates-shoefly

I continue to get this error when I execute my code, any assistance would be greatly appreciated


# define clicks_by_utm here:
percentage_by_utm <- clicks_by_utm %>%
  group_by(utm_source) %>%
  mutate(percentage = count/sum(count))
Error in sum(count): invalid 'type' (closure) of argument

Hide

percentage_by_utm
Error in eval(expr, envir, enclos): object 'percentage_by_utm' not found

I tried to solve for this by adding: summarize(count = n() ) %>%
above the mutate line
but that set each of the percentages to 25% rather than the % for click rate by UTM_Source


Here is the instructions for step 4

To find the percentage of people who clicked on ads from each utm_source , we need to add a new column to ad_clicks that stores the count of clicks (or the count of not clicking) divided by the total number of ad views.

Group clicks_by_utm by utm_source and pipe the result into mutate() , creating a new column percentage that is defined as count/sum(count) .

Save your result to percentage_by_utm and view it. Open the hint for a description of the percentage_by_utm data frame.

Hint

To group together the rows of clicks_by_utm with the same value for utm_source with group_by() :

percentage_by_utm <- clicks_by_utm %>% group_by(utm_source) %>%

To add a column that stores the percentage of users who did or did not click on the ad, pipe the result from the grouping into mutate() and create a new column percentage defined as count/sum(count) :

percentage_by_utm <- clicks_by_utm %>% group_by(utm_source) %>% mutate(percentage = count/sum(count))

  • count represents the number of users who did or did not click on an ad
  • sum(count) represents the total number of users who saw the ad

percentage_by_utm will now contain the click and non-click rates for each utm_source / ad_clicked grouping.

1 Like

I renamed the columns to be more descriptive. However ; that seemed to cause this error.
Re-doing the code exactly as it is in the exercise fixed it.

For me, re-doing the code exactly as it is in the exercise didn’t fix it. I just copied the solution given and it didn’t work.

Is there anyone able to solve it?