library(ggplot2)
library(readr)
ecom <- read_csv('https://raw.githubusercontent.com/rsquaredacademy/datasets/master/ecom.csv',
col_types = list(col_factor(levels = c('Desktop', 'Mobile', 'Tablet')),
col_factor(levels = c(TRUE, FALSE)), col_factor(levels = c(TRUE, FALSE)),
col_factor(levels = c('Affiliates', 'Direct', 'Display', 'Organic', 'Paid', 'Referral', 'Social'))))
## # A tibble: 5,000 x 4
## device bouncers purchase referrer
## <fctr> <fctr> <fctr> <fctr>
## 1 Desktop FALSE FALSE Affiliates
## 2 Mobile FALSE FALSE Affiliates
## 3 Desktop TRUE FALSE Organic
## 4 Desktop FALSE FALSE Organic
## 5 Mobile TRUE FALSE Direct
## 6 Desktop TRUE FALSE Direct
## 7 Desktop FALSE FALSE Referral
## 8 Tablet TRUE FALSE Organic
## 9 Mobile TRUE FALSE Social
## 10 Desktop TRUE FALSE Organic
## # ... with 4,990 more rows
Below is the description of the data set:
fill
color
linetype
size
position
ggplot(ecom) +
geom_bar(aes(factor(device)))
ggplot(ecom) +
geom_bar(aes(factor(device)),
fill = c('red', 'blue', 'green'))
ggplot(ecom) +
geom_bar(aes(device, fill = factor(referrer)))
ggplot(ecom) +
geom_bar(aes(device, fill = factor(referrer)), position = 'dodge')
ggplot(ecom) +
geom_bar(aes(device, fill = factor(referrer)), position = 'fill')
ggplot(ecom) +
geom_bar(aes(factor(device), fill = factor(referrer))) +
coord_flip()
ggplot(ecom) +
geom_bar(aes(factor(device)), fill = 'white',
color = c('red', 'blue', 'green'))
ggplot(ecom) +
geom_bar(aes(factor(device)), fill = 'white',
color = 'black', linetype = 2)
ggplot(ecom) +
geom_bar(aes(factor(device)), fill = 'white',
color = 'black', size = 2)