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

    Function prcomp

    • Principal components of the columns of x (observations as rows). Equivalent to R's prcomp(). The sign of each component is arbitrary, as in R.

      Parameters

      Returns PrcompResult

      const pc = prcomp([[1, 2], [2, 1], [3, 4], [4, 3]]);
      pc.sdev; // [1.632993161855452, 0.816496580927726]
      pc.x; // [[-1.4142, 0.7071], [-1.4142, -0.7071], [1.4142, 0.7071], [1.4142, -0.7071]] (signs may differ from R)
      prcomp([[1, 2], [2, 1], [3, 4], [4, 3]], { rank: 1 }).rotation.length; // 2 (variables; one column each)