-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
77 lines (55 loc) · 3.05 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# **futebolplotR** <a href="https://brunomioto.github.io/futebolplotR/"><img src="man/figures/logo.png" align="right" width="25%" min-width="120px" alt="futebolplotR website" /></a>
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/futebolplotR)](https://CRAN.R-project.org/package=futebolplotR)
<!-- badges: end -->
The goal of **futebolplotR** is to provide functions and geoms that help creating visualization of **Brazilian soccer** related analysis. It provides a ggplot2 geom that does the heavy lifting of plotting Brazilian soccer badges in high quality, with correct aspect ratio and possible transparency.
The **futebolplotR** contains emblems of the teams that have participated in the Brasileirão Série A soccer league from 2003 to the present day. Other teams are also welcome!
This package can be used with data from [brasileirao](https://github.com/williamorim/brasileirao) R package.
The code for this package was **heavily** based on [nbaplotR](https://mrcaseb.github.io/nbaplotR/) with minor changes to support Brazilian soccer team badges.
## Installation
You can install the development version of futebolplotR from [GitHub](https://github.com/brunomioto/futebolplotR/) with:
``` r
if (!require("pak")) install.packages("pak")
pak::pak("brunomioto/futebolplotR")
```
## Using futebolplotR
The key function in the package is `geom_futebol_badges()` which will add Brazilian soccer team badges to a ggplot. Here you can see all the current available teams (currently 44) to plot.
```{r, plot, fig.width = 5, fig.height = 10, dpi=300, message=FALSE, warning=FALSE}
library(futebolplotR)
library(ggplot2)
team <- futebolplotR::valid_team_names()
df <- data.frame(
a = c(rep(1:5, 8),c(1,2,3,4)),
b = sort(c(rep(1:8, 5), c(0,0,0,0)), decreasing = TRUE),
teams = team
)
ggplot(df, aes(x = a, y = b)) +
geom_futebol_badges(aes(team_abbr = teams), width = 0.1) +
geom_label(aes(label = teams,
color = teams,
fill = teams),
nudge_y = -0.35)+
scale_color_futebol(type = "secondary")+
scale_fill_futebol(type = "primary")+
theme_void()+
theme(
plot.margin = margin(15,15,15,15,"pt")
)+
coord_cartesian(clip = "off")
```
For more information on using the package, check out our [**Getting Started**](https://brunomioto.github.io/futebolplotR/articles/futebolplotR.html) article
# Credits
This package was created by [Bruno Mioto](https://github.com/brunomioto) and [Gabriela Junqueira](https://github.com/junqueiragaabi). We thank [Sebastian Carl](https://github.com/mrcaseb) for creating the nflplotR and nbaplotR packages, which were fundamental to the development of futebolplotR.