[rkward-cvs] SF.net SVN: rkward: [1052] trunk/rkward/rkward/plugins/20descriptive

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Jan 2 16:56:03 UTC 2007


Revision: 1052
          http://svn.sourceforge.net/rkward/?rev=1052&view=rev
Author:   tfry
Date:     2007-01-02 08:56:03 -0800 (Tue, 02 Jan 2007)

Log Message:
-----------
Fixes and improvments for descriptive statistics plugin

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

Modified: trunk/rkward/rkward/plugins/20descriptive/code.php
===================================================================
--- trunk/rkward/rkward/plugins/20descriptive/code.php	2007-01-02 16:32:21 UTC (rev 1051)
+++ trunk/rkward/rkward/plugins/20descriptive/code.php	2007-01-02 16:56:03 UTC (rev 1052)
@@ -3,11 +3,13 @@
 	}
 	
 	function calculate () {
+		global $mad_type;
+		global $constMad;
+
 		$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
 		$trim = getRK_val ("trim"); //the fraction (0 to 0.5) of observations to be trimmed from each end of x before the mean is computed
 		$constMad = getRK_val ("constMad");
-		$low = getRK_val ("low");
-		$high = getRK_val ("high");
+		$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"); ?>)
@@ -31,17 +33,24 @@
 	if (rk.temp.options$dosd) rk.temp.results$sd[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$mad[i] <- try (mad (eval (rk.temp.var), constant = <?echo ($constMad) ;?>, <?echo ($low) ;?>, <?echo ($high) ;?>, na.rm=TRUE))
+	if (rk.temp.options$domad) rk.temp.results$mad[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[i] <- try (length (eval (rk.temp.var)))
 	if (rk.temp.options$donacount) rk.temp.results$nacount[i] <- try (length (which(is.na(eval (rk.temp.var)))))
 }<?
 	}
 	
 	function printout () {
+		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) ;?>, "lo-median:", <?getRK ("low") ;?>, "hi-median:", <? getRK ("high") ;?>)))
+					if (rk.temp.options$domad) paste ("constant:", <?echo ($constMad) ;?>, <?
+						if ($mad_type == "low") echo ('"lo-median"');
+						elseif ($mad_type == '"hi-median"');
+						else echo ('"average"'); ?>)))
 
 rk.results (rk.temp.results,
 	titles = c ("Object",

Modified: trunk/rkward/rkward/plugins/20descriptive/description.xml
===================================================================
--- trunk/rkward/rkward/plugins/20descriptive/description.xml	2007-01-02 16:32:21 UTC (rev 1051)
+++ trunk/rkward/rkward/plugins/20descriptive/description.xml	2007-01-02 16:56:03 UTC (rev 1052)
@@ -10,7 +10,7 @@
 						<varselector id="vars" />
 					</column>
 					<column>
-						<varslot multi="true" type="numeric" source="vars" id="x" label="variable(s):" required="true" />
+						<varslot multi="true" type="numeric" source="vars" id="x" num_dimensions="1" label="variable(s):" required="true" />
 					</column>
 				</row>
 			</tab>
@@ -32,14 +32,11 @@
 					<frame label="Median Absolute Deviation (mad)" >
 						<checkbox value_unchecked="0" value="1" id="mad" label="mad" />
 						<spinbox type="real" initial="1.4628" id="constMad" label="Constant" />
-						<radio id="low" label="lo-median" >
-							<option value="low = FALSE" label="FALSE" />
-							<option value="low = TRUE" label="TRUE" />
+						<radio id="mad_type" label="Treatment of even sample sizes" >
+							<option value="low" label="use lo-median" />
+							<option value="average" label="use average" checked="true" />
+							<option value="high" label="use hi-median" />
 						</radio>
-						<radio id="high" label="hi-median" >
-							<option value="high = FALSE" label="FALSE" />
-							<option value="high = TRUE" label="TRUE" />
-						</radio>
 					</frame>
 					<stretch/>
 				</column>


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