Last active
July 1, 2020 21:06
-
-
Save cndesantana/bca84360b0065e1391e583d769054667 to your computer and use it in GitHub Desktop.
R script para plotar figuras descrevendo faturamento e número de empregados das maiores empresas de delivery do mundo. Usadas para post do Dadoscope no Twitter: https://twitter.com/Dadoscope1/status/1278413336074424320
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Dadoscope 2020 | |
| library(tidyverse) | |
| library(waffle) | |
| library(extrafont) | |
| library(echarts4r) | |
| library(fontawesome) | |
| extrafont::font_import (path=".", | |
| pattern = "awesome", prompt = FALSE) | |
| source <- "https://www.owler.com/" | |
| companies <- c("justEat", | |
| "iFood", | |
| "Glovo", | |
| "UberEats", | |
| "Rappi", | |
| "DeliveryHero", | |
| "Postmates", | |
| "Deliveroo", | |
| "Doordash", | |
| "Grubhub", | |
| "Instacart") | |
| revenue <- c(1200, | |
| 240, | |
| 300, | |
| 2500, | |
| 220, | |
| 1600, | |
| 400, | |
| 584, | |
| 900, | |
| 1400, | |
| 2900 | |
| ) | |
| employees <- c(3600, | |
| 1400, | |
| 2800, | |
| 10000, | |
| 1500, | |
| 22000, | |
| 800, | |
| 5699, | |
| 7550, | |
| 2722, | |
| 1200 | |
| ) | |
| dat <- tibble(companies = companies, | |
| revenue = revenue, | |
| employees = employees | |
| ) | |
| plot_iconbarplot <- function(df22, etitle = "", icon_ = "star"){ | |
| df22 %>% | |
| e_charts(x) %>% | |
| e_pictorial(y, symbol = ea_icons(icon_), | |
| symbolRepeat = TRUE, z = -1, | |
| symbolSize = c(20, 20)) %>% | |
| e_theme("westeros") %>% | |
| e_title(etitle) %>% | |
| e_flip_coords() %>% | |
| # Hide Legend | |
| e_legend(show = FALSE) %>% | |
| # Remove Gridlines | |
| e_x_axis(splitLine=list(show = FALSE)) %>% | |
| e_y_axis(splitLine=list(show = FALSE)) %>% | |
| # Format Label | |
| e_labels(fontSize = 16, fontWeight ='bold', position = "right", offset=c(10, 0)) %>% | |
| e_theme("dark") | |
| } | |
| png("trabalhadores_deliveries.png", width=3200,height=1800,res=300) | |
| iron(waffle( | |
| c(`60 Mil Trabalhadores` =60), rows = 6, | |
| colors = "red4", | |
| use_glyph = "male", glyph_size = 12 , | |
| title = '60 Mil Trabalhadores (11 maiores Empresas de Delivery)', legend_pos="none" | |
| )) | |
| dev.off() | |
| png("revenue_deliveries.png", width=3200,height=1800,res=300) | |
| iron(waffle( | |
| c(`12.25 BILHÕES de Dólares faturados em 2019` =60), rows = 6, | |
| colors = "green4", | |
| use_glyph = "money", glyph_size = 12 , | |
| title = 'U$D 12.25 Bi faturados em 2019 (11 maiores Empresas de Delivery)' , legend_pos="none" | |
| )) | |
| dev.off() | |
| library(echarts4r) | |
| library(echarts4r.assets) | |
| dat %>% mutate(revenue = round(revenue), | |
| soma = sum(revenue), | |
| x = as.character(companies), | |
| y = as.integer(revenue)) %>% | |
| select(x,y) %>% | |
| arrange(y) %>% | |
| plot_iconbarplot(., | |
| "Faturamento por empresas de Delivery (em Milhões de Dólares)", | |
| "star") | |
| dat %>% mutate(employees = round(employees), | |
| soma = sum(employees), | |
| x = as.character(companies), | |
| y = as.integer(employees)) %>% | |
| select(x,y) %>% | |
| arrange(y) %>% | |
| plot_iconbarplot(., | |
| "Número de empregados por empresas de Delivery (em Milhões de Dólares)", | |
| "user") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment