This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
library(scales)
library(tidyverse)
library(dbplyr)
library(esquisse)
library(readxl)
bikex <- read_excel("bikex.xlsx")
bikex$year <- format(as.Date(bikex$order_date, format="%Y/%m/%d"),"%Y")
bikes<-bikex%>%select(total_price,category_2,year)
bikey<-bikes%>%group_by(year,category_2)
biebie<-bikey%>%summarise(total_price)
byebye<-biebie%>%group_by(year,category_2)%>%summarise_at(vars(total_price),funs(sum(.,na.rm=TRUE)))
ggplot(byebye) +
aes(x = year, fill = category_2, y = total_price) +
scale_fill_hue(direction = 1) +
labs(
x = "Year",
y = "Revenue",
title = "Revenue by Year",
subtitle = "Upward Trend"
) +
theme_minimal() +
theme(legend.position = "bottom") +
facet_wrap(vars(category_2), scales = "free_y")+geom_col()+geom_smooth(aes(group=1),method = "lm",se=FALSE)+scale_y_continuous(labels = scales::dollar_format())
byebye$numyear<-as.numeric(as.character(byebye$year))
byebye$category_2<-fct_reorder(byebye$category_2,byebye$total_price)
ggplot(byebye) +
aes(x = numyear, y = total_price, fill = category_2 ) +
geom_area(size = 1.5,position = position_stack(reverse = T)) +
scale_fill_hue(direction = 1) +
labs(
x = "Year",
y = "Revenue",
title = "Sales over year by Category_2",
subtitle = "Sales Trending up"
) +
theme_minimal()+scale_y_continuous(labels = scales::dollar_format())+
guides(fill=guide_legend(reverse = T))
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.