[rkward-cvs] SF.net SVN: rkward: [1064] trunk/rkward/rkward/plugins/20descriptive/code. php

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Jan 5 11:50:20 UTC 2007


Revision: 1064
          http://svn.sourceforge.net/rkward/?rev=1064&view=rev
Author:   tfry
Date:     2007-01-05 03:50:20 -0800 (Fri, 05 Jan 2007)

Log Message:
-----------
Change descriptive stastics plugin to produce only the needed code fragments

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/20descriptive/code.php

Modified: trunk/rkward/rkward/plugins/20descriptive/code.php
===================================================================
--- trunk/rkward/rkward/plugins/20descriptive/code.php	2007-01-04 18:04:03 UTC (rev 1063)
+++ trunk/rkward/rkward/plugins/20descriptive/code.php	2007-01-05 11:50:20 UTC (rev 1064)
@@ -12,32 +12,46 @@
 		$mad_type = getRK_val ("mad_type");
 
 ?>
-rk.temp.options <- list (domean=<? getRK ("mean"); ?>, domedian=<? getRK ("median"); ?>, dorange=<? getRK ("range"); ?>, dosd=<? getRK ("sd"); ?>, dosum=<? getRK ("sum"); ?>, doprod=<? getRK ("prod"); ?>, domad=<? getRK ("mad"); ?>, dolength=<? getRK ("length"); ?>, donacount=<? getRK ("nacount"); ?>)
 rk.temp.vars <- list (<? echo ($vars); ?>)
 rk.temp.results <- data.frame ('Object'=rep (NA, length (rk.temp.vars)))
 i=0;
 for (rk.temp.var in rk.temp.vars) {
 	i = i+1
-	rk.temp.results$object[i] <- rk.get.description (rk.temp.var, is.substitute=TRUE)
-	if (rk.temp.options$domean) rk.temp.results$mean[i] <- try (mean (eval (rk.temp.var), trim = <?echo ($trim) ;?>, na.rm=TRUE))
-	if (rk.temp.options$domedian) rk.temp.results$median[i] <- try (median (eval (rk.temp.var), na.rm=TRUE))
-	if (rk.temp.options$dorange) {
-		rk.temp.results$min[i] <- NA
-		rk.temp.results$max[i] <- NA
-		try ({
-			rk.temp.range <- try (range (eval (rk.temp.var), na.rm=TRUE))
-			rk.temp.results$min[i] <- rk.temp.range[1]
-			rk.temp.results$max[i] <- rk.temp.range[2]
-		})
-	}
-	if (rk.temp.options$dosd) rk.temp.results$'standard deviation'[i] <- try (sd (eval (rk.temp.var), na.rm=TRUE))
-	if (rk.temp.options$dosum) rk.temp.results$sum[i] <- try (sum (eval (rk.temp.var), na.rm=TRUE))
-	if (rk.temp.options$doprod) rk.temp.results$prod[i] <- try (prod (eval (rk.temp.var), na.rm=TRUE))
-	if (rk.temp.options$domad) rk.temp.results$'Median Absolute Deviation'[i] <- try (mad (eval (rk.temp.var), constant = <? echo ($constMad);
-		if ($mad_type == "low") echo (", low=TRUE");
-		elseif ($mad_type == "high") echo (", high=TRUE"); ?>, na.rm=TRUE))
-	if (rk.temp.options$dolength) rk.temp.results$'length of sample'[i] <- try (length (eval (rk.temp.var)))
-	if (rk.temp.options$donacount) rk.temp.results$'number of NAs'[i] <- try (length (which(is.na(eval (rk.temp.var)))))
+	rk.temp.results$'Object'[i] <- rk.get.description (rk.temp.var, is.substitute=TRUE)
+<?
+		if (getRK_val ("mean")) { ?>
+	rk.temp.results$mean[i] <- try (mean (eval (rk.temp.var), trim = <?echo ($trim) ;?>, na.rm=TRUE))
+<?		}
+		if (getRK_val ("median")) { ?>
+	rk.temp.results$median[i] <- try (median (eval (rk.temp.var), na.rm=TRUE))
+<?		}
+		if (getRK_val ("range")) { ?>
+	try ({
+		rk.temp.range <- try (range (eval (rk.temp.var), na.rm=TRUE))
+		rk.temp.results$min[i] <- rk.temp.range[1]
+		rk.temp.results$max[i] <- rk.temp.range[2]
+	})
+<?		}
+		if (getRK_val ("sd")) { ?>
+	rk.temp.results$'standard deviation'[i] <- try (sd (eval (rk.temp.var), na.rm=TRUE))
+<?		}
+		if (getRK_val ("sum")) { ?>
+	rk.temp.results$sum[i] <- try (sum (eval (rk.temp.var), na.rm=TRUE))
+<?		}
+		if (getRK_val ("prod")) { ?>
+	rk.temp.results$prod[i] <- try (prod (eval (rk.temp.var), na.rm=TRUE))
+<?		}
+		if (getRK_val ("mad")) { ?>
+	rk.temp.results$'Median Absolute Deviation'[i] <- try (mad (eval (rk.temp.var), constant = <? echo ($constMad);
+			if ($mad_type == "low") echo (", low=TRUE");
+			elseif ($mad_type == "high") echo (", high=TRUE"); ?>, na.rm=TRUE))
+<?		}
+		if (getRK_val ("length")) { ?>
+	rk.temp.results$'length of sample'[i] <- try (length (eval (rk.temp.var)))
+<?		}
+		if (getRK_val ("nacount")) { ?>
+	rk.temp.results$'number of NAs'[i] <- try (length (which(is.na(eval (rk.temp.var)))))
+<?		} ?>
 }<?
 	}
 	
@@ -45,12 +59,12 @@
 		global $mad_type;
 		global $constMad;
 ?>
-rk.header ("Descriptive statistics", parameters=list ("Trim of mean", <?getRK ("trim") ;?>,
-					if (rk.temp.options$domad) "Median Absolute Deviation",
-					if (rk.temp.options$domad) paste ("constant:", <?echo ($constMad) ;?>, <?
+rk.header ("Descriptive statistics", parameters=list ("Trim of mean", <?getRK ("trim") ;?><? if (getRK_val ("mad")) { ?>,
+					"Median Absolute Deviation",
+					paste ("constant:", <?echo ($constMad) ;?>, <?
 						if ($mad_type == "low") echo ('"lo-median"');
 						elseif ($mad_type == '"hi-median"');
-						else echo ('"average"'); ?>)))
+						else echo ('"average"'); ?>)<? } ?>))
 
 rk.results (rk.temp.results)
 <?


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list