/*------------------------------------------------------------------------------* * File Name: GetPartOfADataset.c * * Creation: ER, 03/17/05 * * Purpose: Programming Example * * Copyright (c) OriginLab Corp.2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 * * All Rights Reserved * * * * Modification Log: * *------------------------------------------------------------------------------*/ #include ///////////////////////////////////////////////////////////////////////////////// // This example shows how to get part of a dataset and then perform some // operation with the data // // NOTE: It is assumed that a worksheet is active. // // void get_part_of_a_dataset() { // Declare worksheet and check validity Worksheet wks = Project.ActiveLayer(); if( !wks ) return; // Point to the 2nd column in current wks Column ccData( wks, 1 ); if( !ccData ) return; // Copy rows 10 thru 20 to a vector vector vecSubData( ccData, 9, 19 ); // Trim the vector to eliminate any missing values etc vecSubData.Trim(); // If no data left after trimming, then quit if( 0 == vecSubData.GetSize() ) { out_str("No data left after trimming!"); return; } // The trimmed vector can now be further processed int nNum; double dMean, dSD; if( 0 == ocmath_basic_summary_stats(vecSubData.GetSize(), vecSubData, &nNum, &dMean, &dSD) ) { printf("N = %d, Mean = %f, Std. Dev. = %f\n", nNum, dMean, dSD); } // Note: Making a copy of a dataset column into a vector has // benefits such as using the Trim() method to remove missing values. // On the other hand if one sets lower and upper bounds on the // dataset, there is no way to remove missing values, and also // setting upper/lower bounds affects the worksheet display as // well as display of any graphs that may contain the dataset } /////////////////////////////////////////////////////////////////////////////////