I’m struggling to figure out how to find the percentage of clicks per utm source in this project. I’m stuck on step 4 that says: "

*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."*

The code it gives as the answer is the last line of code I included here and I can’t seem to get it to work. I’m not sure if I’m supposed to replace “count/sum(count)” with anything.

Thanks in advance!!

# Aggregates in R

Hide

```
# load packages
library(readr)
library(dplyr)
```

Hide

```
# load ad clicks data
ad_clicks <- read_csv("ad_clicks.csv")
```

Hide

```
# inspect ad_clicks here:
head(ad_clicks)
```

user_id

utm_source

day

008b7c6c-7272-471e-b90e-930d548bd8d7 google 6 - Saturday 009abb94-5e14-4b6c-bb1c-4f4df7aa7557 facebook 7 - Sunday 00f5d532-ed58-4570-b6d2-768df5f41aed twitter 2 - Tuesday 011adc64-0f44-4fd9-a0bb-f1506d2ad439 google 2 - Tuesday 012137e6-7ae7-4649-af68-205b4702169c facebook 7 - Sunday 013b0072-7b72-40e7-b698-98b4d0c9967f facebook 1 - Monday6 rows | 1-3 of 6 columns

Hide

```
# define views_by_utm here:
views_by_utm <- ad_clicks %>%
group_by(utm_source) %>%
summarize(views = n())
views_by_utm
```

utm_source

views

email 255 facebook 504 google 680 twitter 2154 rows

Hide

```
# define clicks_by_utm here:
clicks_by_utm <- ad_clicks %>%
group_by(utm_source,ad_clicked) %>%
summarize(clicks = n())
clicks_by_utm
```

utm_source

ad_clicked

clicks

email FALSE 175 email TRUE 80 facebook FALSE 324 facebook TRUE 180 google FALSE 441 google TRUE 239 twitter FALSE 149 twitter TRUE 668 rows

Hide

```
# define percentage_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
```