1. Install the package
You can install the development version from GitHub:
install.packages("pak")
pak::pak("gchickering21/Downballot")Or using remotes:
install.packages("remotes")
remotes::install_github("gchickering21/Downballot")Then load the package:
2. First-time setup (required once)
After installing the R package, you must set up the Python
environment used by DownBallotR.
Step 1: Install Python dependencies
Run the following once:
This command:
- Creates a dedicated Python virtual environment for
DownBallotR - Installs required Python packages
- Installs Playwright and its Chromium browser
(this may download ~100–200MB the first time)
This step may take a few minutes.
3. Normal usage (each R session)
Each R session must explicitly activate the Python environment once per session.
Activate Python for the session
At the start of any R session where you plan to use
DownBallotR, run:
This:
- Pins
reticulateto the correct Python virtual environment - Safely initializes Python for the current R session
You only need to run this once per session.
4. Using DownBallotR in future or concurrent sessions
New R session?
If you restart R, open a new RStudio window, or start a separate R process, simply run:
You do not need to reinstall Python.
Multiple R sessions at the same time
If you have multiple R sessions open concurrently:
- Each session must call
downballot_use_python()once - All sessions can safely share the same virtual environment
5. Common issues and fixes
Python is not initialized or packages appear missing
Run:
If packages are still missing:
downballot_install_python(reinstall = TRUE)“reticulate is already initialized to a different Python interpreter”
This occurs when Python is initialized before
calling downballot_use_python().
Fix:
- Restart your R session
- Immediately run:
Then continue using the package.
Reinstall everything from scratch
If the environment becomes corrupted or inconsistent:
downballot_install_python(reinstall = TRUE)
downballot_use_python()
downballot_python_status()