knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

monashtipr

CRAN status Lifecycle: stable CRAN RStudio mirror downloads CRAN RStudio total downloads R-CMD-check Codecov test coverage R-CMD-check

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 from R.

Installation

Install the released version of monashtipr from CRAN:

install.packages("monashtipr")

And the development version from GitHub 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
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.

comp = "normal"
games <- get_games(user, pass, comp = comp)
games
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.

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!

submit_tips(games, user, pass, comp = comp)

Code of Conduct

Please note that the monashtipr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



jimmyday12/monash_tipr documentation built on March 13, 2024, 5:59 a.m.