Class PivotTransform

java.lang.Object
smile.plot.vega.PivotTransform

public class PivotTransform extends Object
The pivot transform maps unique values from a field to new aggregated fields (columns) in the output stream. The transform requires both a field to pivot on (providing new field names) and a field of values to aggregate to populate the new cells. In addition, any number of groupby fields can be provided to further subdivide the data into output data objects (rows). Pivot transforms are useful for creating matrix or cross-tabulation data, acting as an inverse to the fold transform.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toPrettyString

      public String toPrettyString()
      Returns the specification in pretty print.
      Returns:
      the specification in pretty print.
    • limit

      public PivotTransform limit(double limit)
      Sets the maximum number of pivoted fields to generate. The default (0) applies no limit. The pivoted pivot names are sorted in ascending order prior to enforcing the limit.
      Parameters:
      limit - the maximum number of pivoted fields to generate. 0 applies no limit.
      Returns:
      this object.
    • groupby

      public PivotTransform groupby(String... fields)
      Sets the data fields to group by. If not specified, a single group containing all data objects will be used.
      Parameters:
      fields - The data fields to group by. If not specified, a single group containing all data objects will be used.
      Returns:
      this object.
    • op

      public PivotTransform op(String op)
      Sets the aggregation operation to apply to grouped value field values. Default value: sum
      Parameters:
      op - The aggregation operation to apply to grouped value field values.
      Returns:
      this object.