diff --git a/README.md b/README.md
index f7cabc7799..3be95e9e43 100644
--- a/README.md
+++ b/README.md
@@ -990,6 +990,7 @@ The following aggregation methods are supported:
* *median* - the median value
* *deviation* - the standard deviation
* *variance* - the variance per [Welford’s algorithm](https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm)
+* *mode* - the value with the most occurrences
* a function to be passed the array of values for each bin
* an object with a *reduce* method
diff --git a/src/transforms/group.js b/src/transforms/group.js
index 7c6ee2f3b5..b3d7bcb5ae 100644
--- a/src/transforms/group.js
+++ b/src/transforms/group.js
@@ -1,4 +1,4 @@
-import {group as grouper, sort, sum, deviation, min, max, mean, median, variance, InternSet} from "d3";
+import {group as grouper, sort, sum, deviation, min, max, mean, median, mode, variance, InternSet} from "d3";
import {firstof} from "../defined.js";
import {valueof, maybeColor, maybeInput, maybeTransform, maybeTuple, maybeLazyChannel, lazyChannel, first, identity, take, labelof, range} from "../mark.js";
@@ -149,6 +149,7 @@ export function maybeReduce(reduce, value) {
case "mean": return reduceAccessor(mean);
case "median": return reduceAccessor(median);
case "variance": return reduceAccessor(variance);
+ case "mode": return reduceAccessor(mode);
}
throw new Error("invalid reduce");
}
diff --git a/test/output/wordLengthMobyDick.svg b/test/output/wordLengthMobyDick.svg
index c01a5f9d45..5b9cff28d1 100644
--- a/test/output/wordLengthMobyDick.svg
+++ b/test/output/wordLengthMobyDick.svg
@@ -90,19 +90,47 @@
Word length →
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ a
+
+
+ of
+
+
+ the
+
+
+ that
+
+
+ there
+
+
+ though
+
+
+ because
+
+
+ whenever
+
+
+ passenger
+
+
+ passengers
+
+
+ circulation
+
+
+ metaphysical
+
+
+ involuntarily
+
+
+ Circumambulate
+
\ No newline at end of file
diff --git a/test/plots/word-length-moby-dick.js b/test/plots/word-length-moby-dick.js
index 15319707cc..5de3b53024 100644
--- a/test/plots/word-length-moby-dick.js
+++ b/test/plots/word-length-moby-dick.js
@@ -21,7 +21,7 @@ export default async function() {
percent: true
},
marks: [
- Plot.barY(words, Plot.groupX({y: "proportion"}, {x: "length"}))
+ Plot.barY(words, Plot.groupX({y: "proportion", title: "mode"}, {x: "length", title: d => d}))
]
});
}