DataSet

public class DataSet

The DataSet class. This class represents a data set as a “matrix” with cases as rows and variables as columns.

  • Constructs a new empty DataSet.

    Declaration

    Swift

    public init() throws
  • Constructs a DataSet from a CSV-style file. Instead of a comma, a different separator character may be used.

    Declaration

    Swift

    public init (csvName: String, separator: Character)
    throws

    Parameters

    csvName

    the name of the CSV file

    separator

    the separator character (must not be a double-quote character)

  • Constructs a DataSet from a CSV specification provided as a string. Instead of a comma, a different separator character may be used.

    See also

    DataSet.toCSVString(Character)

    Declaration

    Swift

    public init (csvString: String, separator: Character)
    throws

    Parameters

    csvString

    the CSV specification

    separator

    the separator character (must not be a double-quote character)

  • Creates a new column in this DataSet.

    Declaration

    Swift

    public func newColumn(name: String) throws -> Int

    Parameters

    name

    the name of the new column

    Return Value

    the index of the new column

  • Creates a new row in this DataSet.

    Declaration

    Swift

    public func newRow() throws -> Int

    Return Value

    the index of the new row

  • Deletes the specified column from this DataSet. Columns to the right of the deleted column will be shifted one position to the left.

    Declaration

    Swift

    public func delete(column: Int) throws

    Parameters

    column

    the index of the column to be deleted

  • Deletes the specified row from this DataSet. Rows below the deleted row will be shifted one position up.

    Declaration

    Swift

    public func delete(row: Int) throws

    Parameters

    row

    the index of the row to be deleted

  • Sets the name of the specified column of this DataSet.

    Declaration

    Swift

    public func setColumnName(column: Int, name: String) throws

    Parameters

    column

    the index of the column

    name

    the new name of the column

  • Returns the name of the specified column of this DataSet.

    Declaration

    Swift

    public func getColumnName(column: Int) throws -> String

    Parameters

    column

    the index of the column

  • Returns the number of columns in this DataSet.

    Declaration

    Swift

    public func getNumberOfColumns() throws -> Int
  • Returns the number of rows in this DataSet.

    Declaration

    Swift

    public func getNumberOfRows() throws -> Int
  • Moves the specified column to a new position. The columns between the old and the new column positions will be shifted one position to the left or to the right depending on the direction of the move.

    Declaration

    Swift

    public func move(column: Int, to: Int) throws

    Parameters

    column

    the index of the column to be moved

    to

    the index of the destination column

  • Moves the specified row to a new position. The rows between the old and the new row positions will be shifted one position up or down depending on the direction of the move.

    Declaration

    Swift

    public func move(row: Int, to: Int) throws

    Parameters

    row

    the index of the row to be moved

    to

    the index of the destination row

  • Sets (or deletes) the data item at the specified location of this DataSet.

    Declaration

    Swift

    public func setDataItem(row: Int, column: Int, data: String?) throws

    Parameters

    row

    the index of the row

    column

    the index of the column

    data

    the new data item (a nil value causes the item at the specified location to be deleted).

  • Returns the data item at the specified location of this DataSet.

    Declaration

    Swift

    public func getDataItem(row: Int, column: Int) throws -> String?

    Parameters

    row

    the index of the row

    column

    the index of the column

    Return Value

    The data item at the specified location (nil if there is no data)

  • Saves this DataSet in the format of a comma-separated-values (CSV) file. However, a different character than a comma can be used to separate the values.

    Declaration

    Swift

    public func save(csvName: String, separator: Character) throws

    Parameters

    csvName

    the name of the file in which to store the data

    separator

    the delimiter character (must not be a double-quote character).

  • Creates a CSV representation (as a string) of this DataSet.

    Declaration

    Swift

    public func toCSVString(separator: Character) throws -> String

    Parameters

    separator

    the delimiter character (must not be a double-quote character).

    Return Value

    A string containing the CSV representation.