-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
108 lines (79 loc) · 4.34 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
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%"
)
```
# monashtipr
<!-- badges: start -->
[](https://CRAN.R-project.org/package=monashtipr)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
[](https://www.r-pkg.org/pkg/monashtipr)
[](https://www.r-pkg.org/pkg/monashtipr)
[](https://github.com/jimmyday12/monashtipr/actions)
[](https://codecov.io/gh/jimmyday12/monash_tipr?branch=master)
[](https://github.com/jimmyday12/monashtipr/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The goal of `monashtipr` is to provide an R based API that allows users to submit tips to the [Monash University Probabilistic Footy Tipping Competition](https://probabilistic-footy.monash.edu/~footy/) from R.
## Installation
Install the released version of `monashtipr` from CRAN:
```{r cran-installation, eval = FALSE}
install.packages("monashtipr")
```
And the development version from [GitHub](https://github.com/) with:
``` {r, eval = FALSE, results = 'hide'}
# install.packages("devtools")
devtools::install_github("jimmyday12/monashtipr")
```
## Workflow
The two main functions are `get_games()` and `submit_tips`. The general workflow is to use `get_games()` to grab a data frame of the games from a particular round, edit/add your tips and then submit them to the Monash website using `submit_tips`.
First we pull down the games. I've chosen to store my password and username in an Renviron file here to keep them secret, but you could pass these in via plain text. Read up on options for this [here](https://cran.r-project.org/web/packages/httr/vignettes/secrets.html)
```{r store_password}
library(monashtipr)
# Store password and username
# If wanted - store user/password in Renviron file
# e.g. you can run `usethis::edit_r_environ()` and edit them
# MONASH_USER = xxx
# MONASH_PASS = xxx
user <- Sys.getenv("MONASH_USER")
pass = Sys.getenv("MONASH_PASS")
```
Now we can pull games.
```{r get_games, eval=FALSE, include=TRUE}
comp = "normal"
games <- get_games(user, pass, comp = comp)
games
```
```{r show_games, echo=FALSE}
games <- tibble::tribble(
~Game, ~Ground, ~Home, ~Away, ~Margin,
1, "MCG", "Carlton", "Richmond", NA,
2, "MCG", "Collingwood", "Sydney", NA,
3, "MCG", "Essendon", "Hawthorn", NA,
4, "GIANTS Stadium", "G_W_Sydney", "Kangaroos", NA,
5, "GMHBA Stadium", "Geelong", "St_Kilda", NA,
6, "Heritage Bank Stadium", "Gold_Coast", "Adelaide", NA,
7, "MCG", "Melbourne", "W_Bulldogs", NA,
8, "Adelaide Oval", "P_Adelaide", "W_Coast", NA,
9, "Optus Stadium", "Fremantle", "Brisbane", NA
)
games
```
Next - we edit the games data frame to add our tips. How you do this will vary by how you actually store your tips - you might do a join with your existing model output for example. I'll leave that up to the user. A simple example would be to provide a vector of margins.
Please note - these should always be the margin tip of the HOME TEAM.
```{r add_tips}
games$Margin <- c(1, 6, 4, 4, 20, -1, -2, -12, -7)
games
```
Now we just pass this back with our original credentials and we are good to go!
```{r submit_tips, eval=FALSE, include=TRUE}
submit_tips(games, user, pass, comp = comp)
```
## Code of Conduct
Please note that the monashtipr project is released with a [Contributor Code of Conduct](https://jimmyday12.github.io/monash_tipr/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.