Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, September 5, 2019

Codecademy Joining Tables in R Join on Specific Columns II 6/11


#Sample Solution
---
title: "Joining Tables in R"
output: html_notebook
---

```{r message = FALSE}
# load packages
library(readr)
library(dplyr)
```

```{r message = FALSE}
# load orders and products data
orders <- read_csv("orders.csv")
products <- read_csv("products.csv")
```

```{r}
# inspect orders and products
head(orders)
head(products)
```

```{r}
# define orders_products here:
orders_products <- orders %>% inner_join(products, by = c('product_id' = 'id'))
orders_products
```

```{r}
# define products_orders here:
products_orders <- products %>% inner_join(orders, by = c('id' = 'product_id'), suffix = c('_product','_order'))
products_orders
```

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts