Skip to content
Richard Townsend edited this page Aug 10, 2014 · 3 revisions
// Create a new, empty DenseInstances
newInst := base.NewDenseInstances()

// Create some Attributes 
attrs := make([]base.Attribute, 2)
attrs[0] = base.NewFloatAttribute("Arbitrary Float Quantity")
attrs[1] = new(base.CategoricalAttribute)
attrs[1].SetName("Class")

// Add the attributes
newSpecs := make([]base.AttributeSpec, len(attrs))
for i, a := range attrs {
    newSpecs[i] = newInst.AddAttribute(a)
}

Code excerpt: Adding two new Attributes to a blank UpdatableDataGrid

  • Attributes can only be added to empty UpdatableDataGrids (i.e. before calling Extend to allocate memory).
  • AddAttribute returns an [AttributeSpec](Attribute Specifications) describing where the Attribute was inserted.
Clone this wiki locally