Ramda’s R.mean() takes a list of numbers and returns their arithmetic mean. The official docs samples are R.mean([2, 7, 9]) → 6 and R.mean([]) → NaN. Added in v0.14.0. See also R.median.
Internally Ramda computes sum(list) / list.length. That is why an empty list is NaN (0 / 0), and why a one-item list returns that item unchanged.
Syntax
Call R.mean. Start with this line.
Ramda
R.mean(list)
Call
What it does
R.mean(list)
Primary signature.
R.mean(...)
Call the math helper.
Prefer import { mean } from "ramda" when you want a named import.
Library declarations
Ramda
R.mean(list)
Parameters
Parameter
Description
list
Required. an array of numbers. Ramda computes sum(list) / list.length.
Return Value
Return Value
Description
*
Returns a Number: the arithmetic mean.
Ramda Examples
📚 Getting Started
The official average, then how it equals sum divided by length.
R.defaultTo(d, v) returns d when v is null, undefined, or NaN. That turns the official empty-list NaN into a safe zero (or whatever default you pick).
Compatibility
Browser Support
R.mean() is plain JavaScript arithmetic — it runs anywhere Ramda loads: every modern browser plus Node.js. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.14.0+ · Any JS runtime
Ramda.js R.mean()
Load Ramda via CDN or npm, then call R.mean(list). Because it only uses sum divided by length, behavior is identical across engines.
100%With Ramda loaded
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.mean()Universal
Bottom line: Safe in any project that includes Ramda. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node.
Frequently Asked Questions
R.mean(list) returns the arithmetic average of a list of numbers: the sum divided by the length. It is Ramda's unary mean helper, so you can pass it to R.pipe or R.pluck pipelines without writing a lambda.
R.mean([2, 7, 9]) returns 6. R.mean([]) returns NaN. Those are the samples on ramdajs.com/docs/#mean. Added in v0.14.0. See also R.median.
Yes. It has arity 1 and is automatically curried. Call R.mean([2, 7, 9]) for a number. Calling R.mean() with no argument returns a function that waits for the list.
R.mean is the arithmetic average (sum / length). R.median is the middle value after sorting. Outliers pull the mean: R.mean([1, 2, 100]) is about 34.33, while R.median([1, 2, 100]) is 2.
R.sum(list) totals the numbers. R.mean(list) is that total divided by list.length. R.mean is equivalent to R.sum(list) / list.length.
No. R.mean is a stable Ramda math helper from v0.14.0. It is not deprecated, experimental, or non-standard.