R Markdown

df <- readxl::read_excel("Copy of data.xlsx")
library(ggpubr)
## Loading required package: ggplot2
library(dplyr)
## 
## 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(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(ggplot2)
p <- df %>% 
  filter(Product %in% c("Beans","Tea")) %>% 
  ggplot(aes(y = Profit,fill = Product))+
  geom_boxplot()
p

plot_ly(x = NULL, y = df$Profit, type = "box",color = df$Product)
plot_ly(labels = names(table(df$Country)), values = as.numeric(table(df$Country)), type = "pie")
df <- df %>% 
  mutate(time = lubridate::today()-as.Date(Date))
df$time <- as.numeric(df$time)
df <- df %>% 
  mutate(days_group = if_else(time<100,1,if_else(time<300,2,if_else(time<500,3,4))))
gr1 <- df %>% 
  group_by(Product, days_group) %>% 
  summarise(mean_pr = mean(Profit))
## `summarise()` has grouped output by 'Product'. You can override using the
## `.groups` argument.
plot_ly(x = gr1$days_group,y = gr1$mean_pr,color = gr1$Product, type = "scatter",mode = "lines+markers",width = 5) %>% 
  layout(
    title = "The linecharts of the comparison Over Time",
    xaxis = list("Time scores"),
    yaxis = list("Profit")
  )