Hi,
I am having trouble formulating the code needed to make task 8 work. The answer I am getting is 58% and not the ~36.3% expected. I am struggling to see if an error in an earlier stage is causing this error or my formulation of the checkout_no_percent variable is wrong.
Any help or guidance would be appreciated and thanks in advance.
This is my code so far;
t---
title: "Page Visits Funnel"
output: html_notebook
---
```{r message = FALSE, error=TRUE}
# load packages
library(readr)
library(dplyr)
# 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
head(visits)
head(cart)
head(checkout)
head(purchase)
# define visits_cart here:
visits_cart <- visits %>%
left_join(cart)
visits_cart
# define total_visits here:
total_visits = nrow(visits)
total_visits
# define visit_no_cart here:
visit_no_cart <- visits_cart %>%
filter(is.na(cart_time))
visit_no_cart
visit_no_cart_count <- nrow(visit_no_cart)
visit_no_cart_count
# calculate visit_no_cart_percent here:
visit_no_cart_percent <- (visit_no_cart_count/total_visits)*100
visit_no_cart_percent
# define cart_checkout here:
cart_checkout <- cart %>%
left_join(checkout)
cart_checkout
# define total_carts here:
total_carts = nrow(cart)
total_carts
# define cart_no_checkout here:
cart_no_checkout <- cart_checkout %>%
filter(is.na(checkout_time))
cart_no_checkout
cart_no_checkout_count <- nrow(cart_no_checkout)
cart_no_checkout_count
# calculate cart_no_checkout_percent here:
cart_no_checkout_percent <- (cart_no_checkout_count/total_carts)*100
cart_no_checkout_percent
# define all_data here:
all_data <- visits %>%
left_join(cart) %>%
left_join(checkout) %>%
left_join(purchase)
head(all_data)
# define total_checkout here:
total_checkout = nrow(checkout)
total_checkout
# define checkout_no_purchase here:
checkout_no_purchase <- cart_checkout %>%
filter(is.na(checkout_time))
checkout_no_purchase
checkout_no_purchase_count <- nrow(checkout_no_purchase)
checkout_no_purchase_count
# calculate checkout_no_purchase_percent here:
checkout_no_purchase_percent <- (checkout_no_purchase_count/total_checkout)*100
checkout_no_purchase_percent
```ype or paste code here