If you have several Tally accounts, store each account's API key in its
own environment variable in your .Renviron: TALLY_API_KEY for the
default account, and TALLY_API_KEY_<NAME> for named accounts (e.g.
TALLY_API_KEY_WORK for an account called "work"). Account names are
case-insensitive.
Value
tally_accounts() returns a character vector of account
names, "default" first if TALLY_API_KEY is set.
tally_use_account() invisibly returns the name of the previously
active account, so you can restore it later.
Details
tally_accounts() lists the accounts that have a key available.
tally_use_account() switches the active account for the rest of the
session; all tallyr functions then use that account unless given an
explicit account argument.
See also
tally_api_key() for how keys are resolved, tally_sitrep()
to see your accounts at a glance.
Examples
if (FALSE) { # \dontrun{
tally_accounts()
tally_use_account("work")
tally_forms() # uses the "work" account
# one-off call on another account, without switching:
tally_forms(account = "rainbowr")
# switch back, restoring whatever was active before:
previous <- tally_use_account("rainbowr")
tally_use_account(previous)
} # }