Class WindowTransform

java.lang.Object
smile.plot.vega.WindowTransform

public class WindowTransform extends Object
The window transform performs calculations over sorted groups of data objects. These calculations including ranking, lead/lag analysis, and aggregates such as running sums and averages. Calculated values are written back to the input data stream. If you only want to set the same aggregated value in a new field, you can use the simpler join aggregate 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.
    • frame

      public WindowTransform frame(Integer first, Integer last)
      Sets the frame specification indicating how the sliding window should proceed. It is either a number indicating the offset from the current data object, or null to indicate unbounded rows preceding or following the current data object. The default value is [null, 0], indicating that the sliding window includes the current object and all preceding objects. The value [-5, 5] indicates that the window should include five objects preceding and five objects following the current object. Finally, [null, null] indicates that the window frame should always include all data objects. If you this frame and want to assign the same value to add objects, you can use the simpler join aggregate transform. The only operators affected are the aggregation operations and the first_value, last_value, and nth_value window operations. The other window operations are not affected by this.
      Parameters:
      first - the offset of the first object in the sliding window.
      last - the offset of the first object in the sliding window.
      Returns:
      this object.
    • ignorePeers

      public WindowTransform ignorePeers(boolean flag)
      Sets if the sliding window frame should ignore peer values (data that are considered identical by the sort criteria). The default is false, causing the window frame to expand to include all peer values. If set to true, the window frame will be defined by offset values only. This setting only affects those operations that depend on the window frame, namely aggregation operations and the first_value, last_value, and nth_value window operations.
      Parameters:
      flag - If true, ignore peer values.
      Returns:
      this object.
    • groupby

      public WindowTransform groupby(String... fields)
      Sets the data fields for partitioning the data objects into separate windows. If unspecified, all data points will be in a single window.
      Parameters:
      fields - the partitioning fields.
      Returns:
      this object.
    • sort

      public WindowTransform sort(String... fields)
      Sets the fields for sorting data objects within a window. If two data objects are considered equal by the comparator, they are considered "peer" values of equal rank. If sort is not specified, the order is undefined: data objects are processed in the order they are observed and none are considered peers (the ignorePeers parameter is ignored and treated as if set to true).
      Parameters:
      fields - the partitioning fields.
      Returns:
      this object.
    • sort

      public WindowTransform sort(SortField... fields)
      Sets the fields for sorting data objects within a window. If two data objects are considered equal by the comparator, they are considered "peer" values of equal rank. If sort is not specified, the order is undefined: data objects are processed in the order they are observed and none are considered peers (the ignorePeers parameter is ignored and treated as if set to true).
      Parameters:
      fields - the partitioning fields.
      Returns:
      this object.