 	import flash.geom.Point;
 	
 	import mx.collections.ArrayCollection;
-	import mx.controls.Alert;
 	import mx.rpc.AsyncToken;
 	import mx.rpc.events.FaultEvent;
 	import mx.rpc.events.ResultEvent;
 	import mx.utils.ArrayUtil;
 	
 	import weave.Weave;
-	import weave.api.WeaveAPI;
 	import weave.api.disposeObjects;
 	import weave.api.getCallbackCollection;
 	import weave.api.newLinkableChild;

				if (currentTrendline.value == POLYNOMIAL)
				{
					coefficients = ((RresultArray[0] as RResult).value as Array != coefficients) ? (RresultArray[0] as RResult).value as Array : null;
					
					// Preprocess coefficients ==> It might return NaN in higher degree
					for (var i:int = 0; i < coefficients.length; i++)
					{

			{
				//trace( "calculateRegression() " + xColumn.toString() );
				Rstring = "fit <- lm(y~x)\n"
					+"coef <- coefficients(fit)\n" +
						"+ ";
			}
				
			if (currentTrendline.value == POLYNOMIAL)
			{
				Rstring = "fit <- lm(y ~ poly(x, " + polynomialDegree.value.toString() + ", raw = TRUE))\n"
					+"coef <- coefficients(fit)\n";			
			}
			
			if (currentTrendline.value == LOGARITHMIC)
			{
				Rstring = "fit <- lm( y ~ log(x) )\n" 
					+"coef <- coefficients(fit)\n";
			}
			
			
			if (currentTrendline.value == EXPONENTIAL)
			{
				Rstring = "fit <- lm( log(y) ~ x )\n" 
					+"coef <- coefficients(fit)\n";
						
			}
			
			if (currentTrendline.value == POWER)
			{
				Rstring = "fit <- lm( log(y) ~ x )\n" 
					+"coef <- coefficients(fit)\n";
			}
			
			dataXY = ColumnUtils.joinColumns([xColumn, yColumn], Number, false, filteredKeySet.keys);
			
			// sends a request to Rserve to calculate the coefficients of the regression lograrithmic function to xColumn and yColumn
			token = rService.runScript(null, ["x","y"], [dataXY[1], dataXY[2]], ["coef"], Rstring, "", false, false, false);
			addAsyncResponder(token, handleLinearRegressionResult, handleLinearRegressionFault, ++requestID);

		}
		
