Page Visits Funnel

I’m having an error:

Error in eval(lhs, parent, parent): object 'all_data' not found

This is due to this:

all_data <- all_data %>%
  mutate(time_to_purchase = purchase_time - visit_time)

Can you explain to me what I should change so it can work properly?

Please post a link to the lesson or project page. Thanks,

1 Like

Not familiar with R but going through the unit on Joining Tables to see if anything jumps out.

We will probably need to see all your code to this point. Please post that in a new post.

That’s not what we need. We need the raw code in text form, formatted.

title: "Page Visits Funnel"
output: html_notebook

```{r message = FALSE, error=TRUE}
# load packages
# load data
visits <- read_csv("visits.csv")
cart <- read_csv("cart.csv")
checkout <- read_csv("checkout.csv")
purchase <- read_csv("purchase.csv")
# inspect data frames
# define visits_cart here:
visits_cart <- visits %>%

# define total_visits here:
total_visits = nrow(visits)

# define visit_no_cart here:
visit_no_cart <- visits_cart %>%

visit_no_cart_count <- nrow(visit_no_cart)
# calculate visit_no_cart_percent here:
visit_no_cart_percent <- visit_no_cart_count/total_visits

# define cart_checkout here:
cart_checkout <- cart %>% 

# define total_carts here:
total_carts = nrow(cart)

# define cart_no_checkout here:
cart_no_checkout <- cart_checkout %>% 

cart_no_checkout_count <- nrow(cart_no_checkout)
# calculate cart_no_checkout_percent here:
cart_no_checkout_percent <- cart_no_checkout_count/total_carts
# define all_data here:
all_data <- all_data %>%
  mutate(time_to_purchase = purchase_time - visit_time)

# define total_checkout here:

# define checkout_no_purchase here:

# calculate checkout_no_purchase_percent here:

# update all_data with time_to_purchase column here:

# inspect the updated all_data data frame here:

# define time_to_purchase here:

1 Like

This is defining all_data, so what variable should be on the right side?

All the data that has been calculated, so far.

Your issue is here

you’re trying to pipe all_data in when all_data hasn’t been defined yet. Piping is a useful tool in r but since all_data hasn’t actually been defined yet, so you’re trying to mutate the column time_to_purchase on a data frame that doesn’t exist yet. You need to define all_data initially through what I believe in the exercise is left joining all your stages together, then you can execute that step.

1 Like

How do I do that, exactly?

Right here you create visits_cart by doing a left join of cart onto visits. for all_data you just want to do a similar thing but by doing a left_join of all the steps, one after another aka.
visits -> cart -> checkout -> purchase.

That is seems very confusing to me.

You’re just taking what you’ve already done and stacking it up, so what you end up with is

all_data <- visits %>%
  left_join(cart) %>%
  left_join(checkout) %>%

and that’s all_data defined! Then your code you originally had the issue with should work fine.

It worked, thanks bro.

I’m having a new issue with the time_to_purchase:

time_to_purchase <- all_data %>%
  summarize(mean_time = mean(time_to_purchase, na.rm = TRUE))

This is the error I get:

# update all_data with time_to_purchase column here:
time_to_purchase <- all_data %>%
  summarize(mean_time = mean(time_to_purchase, na.rm = TRUE))

Error in mean(time_to_purchase, na.rm = TRUE): object 'time_to_purchase' not found
Error in eval(expr, envir, enclos): object 'time_to_purchase' not found

Can I see the code you have used for adding the time_to_purchase column into the all_data dataset.

Oh yeah, I completely get you. What should I replace all_data with?

You don’t need to replace all_data, your code is correct in its current state. The issue is you haven’t added the time_to_purchase column into all_data which should have been done in a previous step.

What should be included when making a time_to_purchase column. Since I don’t think I have made that yet.