rStats.js v1.3.0
    Preparing search index...

    Function subset

    • The rows of a data frame that meet a condition, and optionally some of its columns. Equivalent to R's subset(). For a data frame: keep is a boolean per row or a function of the row; a missing (null) or non-boolean result counts as false, as R drops the rows whose condition is NA.

      Parameters

      Returns DataFrame

      const d = { y: [5, NaN, 7, 2], g: ["a", "b", "a", "b"] };
      subset(d, (row) => (row.y as number) > 4); // { y: [5, 7], g: ["a", "a"] }
      subset(d, [true, true, false, false], { select: ["g"] }); // { g: ["a", "b"] }