When you're hacking on this package locally, you can test it by installing from source:
bash
cd /path/to/git/ausplotsR/
bash
R
devtools
and roxygen2
are installed, you only need to do this
once
R
install.packages("devtools")
install.packages("roxygen2")
R
devtools::install_deps(pkg='.')
devtools::load_all
(doco) function to load
the package from source. There is no argument to this function as it looks
in your current working directory:
R
# check your working directory with
# getwd()
# ...and set your working directory with
# setwd('/path/to/dir')
devtools::load_all()
devtools::load_all()
to reload.The load_all()
function defaults to exporting everything so you can access all
package private functions to test them.
You might also want to change the URL of the API that is used (to your local machine?). To do so, we need to set an R option:
devtools::load_all()
options("ausplotsR_api_url" = "http://localhost:30000")
#...continue to call functions
You can check the current setting of the API URL with:
getOption("ausplotsR_api_url")
You can also set an option to turn on (or off) debug logs:
options("ausplotsR_api_debug" = TRUE)
#...continue to call functions
To test that the package can install into a fresh environment, we can use a Docker container. Note that this will use the repo you have locally, but it WILL NOT use dirty working directory state. It installs clean commits only.
bash
cd ausplotsR/ # root of this repo
docker run \
--rm \
-it \
--name=ausplotsr-test \
-v `pwd`:/app \
zamora/r-devtools
R
devtools::install_git('/app', ref = 'somebranch') # ref can be branch or commit
R
library(ausplotsR)
If you prefer to use a GUI version of R, we can use an RStudio docker image:
bash
cd ausplotsR/ # root of this repo
docker run \
-e PASSWORD=somepassword \
--rm \
--name=ausplotsr-test \
-v `pwd`:/app \
-p 8787:8787 \
rocker/tidyverse
rstudio
with password somepassword
To install a specific branch from GitHub, for example somebranch
, use the following command:
devtools::install_github("ternaustralia/ausplotsR@somebranch")
For developers: the server-side mechanism to allow this is described in the docs for the server.
By default the public (unauthorised users) can only access site visits that are marked as published in the database.
The database also contains unpublished data. If you authorise yourself, you can access these unpublished records.
Follow these steps to access the unpublished site visits:
R
ausplotsR:::set_auth('somerole', 'somesecret')
R
ausplotsR:::unset_auth()
The authorisation will expire. If you leave your R session open for a really long time, you might see an error like:
Error in .ausplots_api(path, query) : Unauthorized (HTTP 401).
If this is the case, re-run the set_auth()
function and things should start
working again.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.