load dataframe # Create a 2D matrix: var matrix = array( 16 ){ [i] [ -1.0 : -1 : 8] + 1.51*i } # Create a 2D dataframe from the matrix: var dframe2d = DataFrame( matrix ) # Add row labels: dframe2d.AddLabels( $row, { 'RR1' => 0, 'R2' => 1, 'RRRR5' => 5 } ) dframe2d.AddLabels( $row, { 'RR1' => 0, 'R2' => 1, 'RRRR5' => 6 } ) # Add column labels: dframe2d.AddLabels( $column, { 'CC1' => 0, 'C2' => 1, 'CCCCCCCCC3' => 4 } ) dframe2d.AddLabels( $column, { 'CC1' => 0, 'C2' => 1, 'CCCCCCCCC3' => 5 } ) # Add string column: dframe2d.AddColumn( { 'ABC', 'DEF', 'SSSS', 'Hello\t world!' }, 'String' ) # Add column of arbitrary type: dframe2d.AddColumn( { {'ABC'}, {'DEF', 'SSSS'}, 'Hello\n world!' }, 'Any' ) # Add integer column: dframe2d.AddColumn( [ 123, 456, 7890], 'Number' ) # Formated printing: io.writeln( dframe2d ) # Update one cell: dframe2d[0,1] = 1000000.23 var col = [0:100:9] col.transpose() var col2 = array(9){ [i] [100*i] } io.writeln( col, col2 ) # Update one column: dframe2d[1:10,2] += col # Add the first column to the second: dframe2d[:,1] += dframe2d[:,0] io.writeln( dframe2d ) # Print a slice: dframe2d[1:5,4:].Print() # Scan cells: dframe2d[1:5,:3].ScanCells { [value,row,column] io.writeln( row, column, value ) } # Scan rows: dframe2d[1:5,:3].ScanRows { [value,row] io.writeln( row, value ) } # Scan columns: dframe2d[1:5,:3].ScanColumns { [value,column] io.writeln( column, value ) } # Create a 3D matrix: var matrix3d = array(3){ [i] matrix + i } matrix3d.permute( 2, 1, 0 ) # Create 3D dataframe: var dframe3d = DataFrame( matrix3d ) #dframe3d.AddLabels( $row, { 'RR1' => 0, 'R2' => 1, 'RRRR5' => 5 } ) io.writeln( dframe3d )