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. The automatic-loading step at the end of this page uses a small file that lives inside your Project, so it helps to have one ready.
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)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.
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.
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:
jstats has been updated.
Restart R to load it in RStudio:
- open the Session menu > choose Restart R
- or press Ctrl+Shift+F10
The Console will return to a blank 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.)
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.
Load jstats automatically (recommended)
You can tell your Project to load jstats for you every time it opens, so you never have to type library(jstats) again. It’s optional, but worth doing: besides saving the keystrokes, it means the package’s automatic update check runs every time you start work — so you’re always told when a new version is available — and you open each session ready to go. This uses a small setup file called an .Rprofile (a file R reads automatically when it starts).
Create a plain text file named .Rprofile in your Project folder containing these two lines:
# To reinstall jstats (new computer, or after updating R) see the install code at: jma61.github.io/jstats-guides/install-jstats.html
library(jstats)The second line does the loading. The first is a comment — R ignores any line that starts with # — holding the address of this page, so the reinstall instructions are one glance away on a new computer or after an R update. Keep the # in place: without it, R would try to run the address as a command at every startup and complain; with it, the line is just a note that costs nothing.
Save it, then restart R (Session menu, Restart R). From now on, every session in this Project starts with jstats already loaded.
Keep this to lightweight startup lines — loading a package, and later a setting or two. Do not put an install command (like the install.packages("jstats", ...) line above) in .Rprofile: because the file runs on every startup, an install line there tries to reinstall each time and can send RStudio into a loop. Installing is a one-off you run by hand; loading is the repeatable step that belongs in startup.
We’re keeping this minimal for now. Later you’ll add a line or two more — where your data lives, and how many digits to show in output — but this is plenty to start.
This .Rprofile lives inside your Project and applies only to this Project. That’s deliberate — it’s self-contained and safe to edit. There’s also a global, all-Projects version, but it’s better left until you’re juggling several Projects at once; the books cover it.
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.