Skip to contents

Example

In this vignette we are going to see an example of the usage of this package first, let’s start by loading in the package

# install.packages("lotterybr")
library(lotterybr)
library(ggplot2)

Let’s suppose that we want to see the data of numbers of the game megasena in portuguese, therefore we can do

megasena_numbers = get_data(game = "megasena", type = "numbers", language = "ptbr")
head(megasena_numbers)
## # A tibble: 6 × 4
##   data       concurso acumula dezenas
##   <date>        <int> <chr>   <fct>  
## 1 1996-03-11        1 sim     04     
## 2 1996-03-11        1 sim     05     
## 3 1996-03-11        1 sim     30     
## 4 1996-03-11        1 sim     33     
## 5 1996-03-11        1 sim     41     
## 6 1996-03-11        1 sim     52

Or, if we want to see the winners of lotofacil in portuguese

lotofacil_winners = get_data(game = "lotofacil", type = "winners", language = "eng")
head(lotofacil_winners)
## # A tibble: 6 × 6
##   date       course accumulated match winners   prize
##   <date>      <int> <chr>       <chr>   <int>   <dbl>
## 1 2003-09-29      1 no          15          5  49766.
## 2 2003-09-29      1 no          14        154    690.
## 3 2003-09-29      1 no          13       4645     10 
## 4 2003-09-29      1 no          12      48807      4 
## 5 2003-09-29      1 no          11     257593      2 
## 6 2003-10-06      2 no          15          1 596324.

We can use this data to create plots

ggplot(lotofacil_winners, aes(x = factor(match), y = winners, fill = match)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(x = "Match", y = "Winners frequency", title = "Winners by Match") +
  theme_minimal()

or to analyse the data:

df = data.frame(
  dezenas =summary(
    megasena_numbers$dezenas
    )
  )
summary(df$dezenas)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   239.0   276.8   289.5   289.8   305.0   345.0
head(df)
##    dezenas
## 01     272
## 02     287
## 03     269
## 04     305
## 05     315
## 06     293