CompStatsLib

TypeScript / JavaScript package

@compstats/core

The version of @compstats/core on npm Monthly downloads of @compstats/core from npm The package is MIT licensed

The browser port of the R package. The R original runs in RStudio. This one runs in a browser, with no R installation and no server.

bun add @compstats/core

npm install @compstats/core works the same way. The install is small, because the package brings nothing with it. Plotly is an optional peer, and only the 3D functions need it. The package sits on npm, and the source is on GitHub.

Three layers, used alone A core function computes the statistics and touches no DOM. A plot function draws on a target you give it. An interactive component owns the input and redraws on every click. linearRegression() · plotRegression() · interactiveRegression()
2D on a canvas, 3D on demand The 2D plots draw on a plain canvas. The 3D plots sit behind a separate entry point, so a page that shows only 2D never downloads Plotly. import { interactiveScatter3d } from "@compstats/core/3d"
The statistics base R gives away JavaScript has no statistics standard library, so the port wrote one: descriptives, the t distribution, seeded samplers, density, and small linear algebra. Each follows its R counterpart. quantile() · dt() · rnorm() · kernelDensity() · invertMatrix()

A page can load it with no build step

The main bundle is self-contained browser ESM with no imports of its own. A CDN can serve it straight to a script tag.

import { interactiveTTest } from "https://esm.sh/@compstats/core";

Every component returns a handle. getValues() gives back the options that draw the same picture again, which is what this site saves into a shareable link.