Learn
This lesson introduced some methods for combining multiple data frames:
- Creating a data frame made by matching the common columns of two data frames is called a
join
- We can specify which columns should be matched by using the
by
argument - We can combine data frames whose rows don’t all match using
left
,right
, andfull
joins - We can stack or concatenate data frames with the same columns using
bind_rows()
Instructions
1.
Cool T-Shirts Inc. just created a website for ordering their products. They want you to analyze two datasets for them:
visits
contains information on all visits to their landing pagecheckouts
contains all users who began to checkout on their website
Use head()
to inspect each data frame.
2.
We want to know the amount of time from a user’s initial visit to the website to when they start to check out.
Use inner_join
to combine visits
and checkouts
and save it to the variable v_to_c
. View v_to_c
.
3.
In order to calculate the time between visiting and checking out, define a column of v_to_c
called time
by pasting the following code into notebook.Rmd:
v_to_c <- v_to_c %>% mutate(time = checkout_time - visit_time) v_to_c
4.
To get the average time to checkout, paste the following code into notebook.Rmd:
avg_time_to_check <- v_to_c %>% summarize(mean_time = mean(time)) avg_time_to_check
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.