 			
 			if (currentTrendline.value == POWER)
 			{
-				Rstring = "fit <- lm( log(y) ~ x )\n" 
+				Rstring = "fit <- lm( log(y) ~ log(x) )\n" 
 					+"coef <- coefficients(fit)\n" 
 					+"rSquared <- summary(fit)$r.squared\n";
 			}

			// R only returns coefficients and rSquared
			if (RresultArray.length == 2)
			{
				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
				// where it should in fact be 0.
				for (var i:int = 0; i < coefficients.length; i++)
				{
					if (isNaN(coefficients[i]))

		 **/
		private function evalFunction(type:String, coefficients:Array, xValue:Number):Number
		{
				
			var b:Number = coefficients[0];
			var a:Number = coefficients[1];
			
			if (type == POLYNOMIAL) 
			{
