Install jstats
This page gets the jstats package installed and loaded, ready to use. It assumes you’ve already installed R and RStudio and have an RStudio Project open. If you haven’t, work through Install R and RStudio and RStudio Orientation first, then come back here.
If you’ve installed R packages before, this is ordinary install-and-load with one small wrinkle. jstats isn’t on CRAN yet, so it installs from an r-universe repository (a free, CRAN-like service that publishes ready-made package binaries). In practice that means a single install.packages() call with a repos argument — the r-universe repository for jstats itself, plus a regular CRAN mirror for any supporting packages — shown just below. Because you’re installing a binary, nothing is compiled, so there’s no need for Rtools (Windows) or Apple’s command line tools (Mac), and no remotes or GitHub step. jstats also checks for a newer version each time it loads, and jupdate() updates it in a single command. Jump to the install line below — the rest is the install-and-load you already know.
What you need first
Before the steps below, make sure you have:
- R and RStudio installed — see Install R and RStudio.
- An RStudio Project open — RStudio Orientation covers creating one.
Install jstats and load it
jstats installs with a single command. Click in the Console (bottom-left pane), paste the two lines below, and press Enter — the first installs jstats, the second loads it:
install.packages("jstats",
repos = c("https://jma61.r-universe.dev", "https://cloud.r-project.org"))
library(jstats)You may see a red WARNING that Rtools is required. That’s normal and not an error — jstats installs without it. And if R asks whether you want to install from sources, click No.
The repos part just tells R where to look: the first address is the r-universe repository where jstats is published, and the second is an ordinary CRAN mirror that supplies any of jstats’s supporting packages you don’t already have. Both hand over ready-made versions, so nothing is built from source and the install is quick.
Two words are about to start doing a lot of work, and they’re easy to mix up.
A package is the thing you install — jstats is a package. A library is a folder on your computer where your installed packages are kept. install.packages() puts jstats into the library; library(jstats) fetches it back out for the session. The command is named after the folder it fetches from.
That’s also why R can answer a line that says library with an error that says package: it looked in the folder, and the package wasn’t there. And it’s why updating R means installing your packages again — a new version of R starts with a fresh, empty library.
Installing is normally a once-per-computer job — plus once more if you ever update R itself, which comes out in a new version about once a year and starts a fresh package library when it does. Worth bookmarking: this page always carries the current install line, so it’s the one to come back to on a new computer or after an R update. (If library(jstats) ever fails after updating R, the Troubleshooting page has the details.)
On the first install — or the first time you load jstats after updating R — you may see a line like package 'jstats' was built under R version 4.x.x. That’s normal and needs no action: it only means the ready-made copy was built on a slightly different R version than the one you’re running. It clears the next time you update R.
If it loaded cleanly, you’ll see a short jstats startup message — and, if a newer version is already out, a note with the exact lines to update (more on that below). That message is how you know jstats is loaded and ready.
You’ll run library(jstats) at the start of each session. Prefer not to? You can set your Project to load it for you automatically — see Loading jstats automatically.
If the install fails
The most common snags are below — scan the titles and open the one that matches your error. If yours isn’t here, the full Troubleshooting page has more.
The simplest fix is to remove jstats and install it fresh:
remove.packages("jstats")
install.packages("jstats",
repos = c("https://jma61.r-universe.dev", "https://cloud.r-project.org"))
library(jstats)This almost always means an install command was put in your .Rprofile. That file runs every time R starts, so an install line tries to reinstall on every startup and can loop. Your .Rprofile should only ever hold lightweight startup lines like library(jstats) — never an install command. To recover: close RStudio, open your Project folder in your computer’s file manager, open the .Rprofile file in a plain text editor (Notepad on Windows, TextEdit on Mac), delete the install line, keeping the library(jstats) line (and its reminder comment, if your .Rprofile has one), save, and reopen RStudio.
Keep jstats up to date
Because jstats is updated often during this phase, it checks for a newer version each time you load it with library(jstats). When one is available, it prints a short message at startup — the new version number and the one command to run. That command is:
jupdate()Run it in the Console and jstats updates itself: one command, with nothing to copy or keep track of. jupdate() first checks that you’re online and that you aren’t already on the latest version (if you are, it just says so and stops), then downloads and installs the new version. It doesn’t pause to ask “are you sure?” — it goes ahead and updates.
One thing to know: installing the new version and loading it are two separate steps. jupdate() puts the new version on your computer, but the session you’re in keeps running the old one until you restart R. You don’t have to remember how — when the update finishes, jupdate() prints the exact steps, after a list of what is new in each version since the one you had (left out of the copy below):
jstats has been updated to version x.y.z.
Restart R to load it in RStudio:
- open the Session menu > choose Restart R
- or press Ctrl+Shift+F10
If your startup loads packages automatically, their usual messages will appear
after the restart; otherwise the Console returns to an empty prompt.
Reload jstats with library(jstats) (unless loaded automatically on startup).
Follow those and you’re running the new version.
(This all gets simpler once jstats reaches CRAN: jupdate() keeps working, just updating the ordinary way, and we’ll revise these instructions then.)
Keeping jstats current is only part of the picture — R and RStudio update on their own separate schedules, and they don’t work the same way. The Updating page pulls all three together, including what to do after an R update and when to set up a new computer.
A couple of extra options. If you’d rather confirm before anything installs, run jupdate(ask = TRUE) — it shows the available and installed versions and waits for your okay. Updates are reliable here because jupdate() installs in a separate R process, so the copy loaded in your session never has to overwrite its own files mid-update (the usual cause of a failed update on Windows). And to silence the startup check entirely — for instance on a machine that’s on a network but has no internet — set options(jstats.check_updates = FALSE).
While jstats is in this pre-release phase, it’s still actively growing — which makes now the best time to ask for things. If a function is missing an option your work needs, or you’d like an analysis it doesn’t yet cover, say so by email: SurveyCentre@griffith.edu.au. If you hit an error, include the full error message, what you ran, and which versions of R and jstats you’re on (you can get those by running R.version.string and packageVersion("jstats")) — that detail makes a fix far quicker. Changes are far easier to fold in now than after the package reaches its stable release, where keeping existing code working limits what can change.
A concrete example of feature-by-request: a researcher wanted to see which cells drive a significant chi-square, so adjusted standardized residuals were added to the cross-tabs function — jcrosstab(Education ~ Volunteer, data = community, residuals = "adjusted"). That kind of targeted addition is exactly what this phase is for.
What to expect at this early stage
Using jstats during its pre-release phase comes with a simple, honest trade. The costs are small and real: the occasional error message that reads more cryptically than it should, and now and then a feature you wish were there but isn’t yet. The benefit is results fast — and, as the note above says, a direct line to shape what gets built next.
There’s also a safety net that makes the trade an easy one. jstats is a convenience layer, not a cage. Anything it doesn’t do, plain R still does — you can always drop back to base R, or reach for another package, right alongside jstats in the very same script. That’s the intended path: use jstats for the common social-science tasks it’s built for, pick up a little real R painlessly as you go, and when you eventually need something specialized it doesn’t cover, you’ll have learned enough to add the package that does. You’re never stuck, and you’re never learning a dead end.
With jstats installed and loaded, the jstats Quick Start puts it to work.