Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.

library(ggplot2)          # for plotting capabilities
library(completejourney)  # for data
## Welcome to the completejourney package! Learn more about these data
## sets at http://bit.ly/completejourney.
library(dplyr)            # for additional data wrangling
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble  3.1.8     ✔ purrr   1.0.1
## ✔ tidyr   1.2.1     ✔ stringr 1.5.0
## ✔ readr   2.1.3     ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(gridExtra)
## 
## Attaching package: 'gridExtra'
## 
## The following object is masked from 'package:dplyr':
## 
##     combine
plot1 <- 
transactions_sample %>% 
  inner_join(demographics, by = "household_id") %>%
  group_by(kids_count) %>%
  summarize(discounts_applied = sum(retail_disc)) %>%
  arrange(desc(discounts_applied))

plot2 <-
transactions_sample %>%
  inner_join(demographics, by = "household_id") %>%
  group_by(kids_count) %>%
  summarize(retail_amount = sum(sales_value)) %>%
  arrange(desc(retail_amount))

plot3 <-
transactions_sample %>%
  inner_join(demographics, by = "household_id") %>%
  group_by(kids_count) %>%
  summarize(total_quantity = sum(quantity)) %>%
  arrange(desc(total_quantity))

plot1
plot2
plot3
Final_Plot1<- ggplot(plot1, aes(x = kids_count, y = discounts_applied)) +
  geom_point() +
  geom_line()+
  labs(
    title = "Total Discounts Applied Per Household Grouped by Kids Count",
    subtitle = "This plot compares the total discounts applied per household depending on the kids count",
    y = "Discounts Applied",
    x = "Kids Counts",
  ) 


Final_Plot2 <- ggplot(plot2, aes(x = kids_count, y = retail_amount)) +
  geom_point() +
  geom_line()+
  labs(
    title = "Total Amount of Dollars The Retailer Recieves From Sale",
    subtitle = "This plot compares the total amount of dollars the retailer receives from sale depending on the kids count",
    y = "Retail Amount",
    x = "Kids Counts",
  ) 

Final_Plot3 <- ggplot(plot3, aes(x = kids_count, y = total_quantity)) +
  geom_point() +
  geom_line()+
  labs(
    title = "Total Number of Products Purchased During Trip depending on the Kids Count",
    subtitle = "This plot compares the total number of products purchased during the trip depending on the kids count",
    y = "Product Purchased",
    x = "Kids Counts",
  ) 
grid.arrange(Final_Plot1, Final_Plot2, Final_Plot3)
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?
## `geom_line()`: Each group consists of only one observation.
## ℹ Do you need to adjust the group aesthetic?

When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).

The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.