[rkward-cvs] SF.net SVN: rkward: [1071] trunk/rkward/rkward/plugins

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Jan 7 15:29:51 UTC 2007


Revision: 1071
          http://svn.sourceforge.net/rkward/?rev=1071&view=rev
Author:   tfry
Date:     2007-01-07 07:29:51 -0800 (Sun, 07 Jan 2007)

Log Message:
-----------
Plugin coding style

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/descriptive/skewness_kurtosis_test.php
    trunk/rkward/rkward/plugins/distributions/ad_test.php
    trunk/rkward/rkward/plugins/distributions/ad_test.xml

Modified: trunk/rkward/rkward/plugins/descriptive/skewness_kurtosis_test.php
===================================================================
--- trunk/rkward/rkward/plugins/descriptive/skewness_kurtosis_test.php	2007-01-07 15:13:15 UTC (rev 1070)
+++ trunk/rkward/rkward/plugins/descriptive/skewness_kurtosis_test.php	2007-01-07 15:29:51 UTC (rev 1071)
@@ -6,57 +6,41 @@
 	$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
 
 ?>
-	
-	require(moments)
+require(moments)
 
-	rk.temp.options <- list (doskewness=<? getRK ("skewness"); ?>, dokurtosis=<? getRK ("kurtosis"); ?>, dolength=<? getRK ("length"); ?>, donacount=<? getRK ("nacount"); ?>)
-
-	rk.temp.results <- list ()
-	i=0; for (var in list (<? echo ($vars); ?>)) {
+rk.temp.objects <- list (<? echo ($vars); ?>)
+rk.temp.results <- data.frame ('Variable Name'=rep (NA, length (rk.temp.objects)), check.names=FALSE)
+i=0;
+for (var in rk.temp.objects) {
 	i = i+1
-	rk.temp.results[[i]] <- list ()
-	rk.temp.results[[i]]$object <- rk.get.description (var, is.substitute=TRUE)
-	if (rk.temp.options$doskewness) try (rk.temp.results[[i]]$skewness <- skewness (eval (var), <? getRK ("narm_skewness"); ?>))
-	if (rk.temp.options$dokurtosis) try (rk.temp.results[[i]]$kurtosis <- kurtosis (eval (var), <? getRK ("narm_kurtosis"); ?>))
-	if (rk.temp.options$dolength) try (rk.temp.results[[i]]$length <- length (eval (var)))
-	if (rk.temp.options$donacount) try (rk.temp.results[[i]]$nacount <- length (which(is.na(eval (var)))))
+	rk.temp.results$'Variable Name'[i] <- rk.get.description (var, is.substitute=TRUE)
+	<? 
+	if (getRK_val ("skewness")) { ?>
+	try (rk.temp.results$'Skewness'[i] <- skewness (eval (var), <? getRK ("narm_skewness"); ?>))
+	<? }
+	if (getRK_val ("kurtosis")) { ?>
+	try (rk.temp.results$'Kurtosis'[i] <- kurtosis (eval (var), <? getRK ("narm_kurtosis"); ?>))
+	<? }
+	if (getRK_val ("length")) { ?>
+	try (rk.temp.results$'Length'[i] <- length (eval (var)))
+	<? }
+	if (getRK_val ("nacount")) { ?>
+	try (rk.temp.results$'NAs'[i] <- length (which(is.na(eval (var)))))
+	<? } ?>
 }
-
-
 <?
         }
 	function printout () {
-?>	
-	 rk.header("Skewness and Kurtosis")
-
-cat ("<table border=\"1\">")
-	cat ("<tbody>")
-		cat ("<tr>")
-			cat ("<td>Variable Name</td>")
-			if (rk.temp.options$dolength) cat ("<td>Length</td>")
-			if (rk.temp.options$donacount) cat ("<td>NAs</td>")
-			if (rk.temp.options$doskewness) cat ("<td>Skewness</td>")
-			if (rk.temp.options$dokurtosis) cat ("<td>Kurtosis</td>")
-		cat ("</tr>")
-for (i in 1:length (rk.temp.results)) {
-		cat ("<tr><td>", rk.temp.results[[i]]$object, "</td>")
-		if (rk.temp.options$dolength) cat ("<td>", rk.temp.results[[i]]$length, "</td>")
-		if (rk.temp.options$donacount) cat ("<td>", rk.temp.results[[i]]$nacount, "</td>")
-		if (rk.temp.options$doskewness) cat (paste ("<td>", rk.temp.results[[i]]$skewness,"</td>"))
-		if (rk.temp.options$dokurtosis) cat (paste ("<td>", rk.temp.results[[i]]$kurtosis,"</td>"))
-		cat ("</tr>")
-}
-	cat ("</tbody>")
-cat ("</table>")
-
-
+?>
+rk.header ("Skewness and Kurtosis")
+rk.results (rk.temp.results)
 <?
         }
 	function cleanup () {
 
 ?>
 	rm (rk.temp.results)
-	rm (rk.temp.options)
+	rm (rk.temp.objects)
 	rm (var)
 <?
         }

Modified: trunk/rkward/rkward/plugins/distributions/ad_test.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/ad_test.php	2007-01-07 15:13:15 UTC (rev 1070)
+++ trunk/rkward/rkward/plugins/distributions/ad_test.php	2007-01-07 15:29:51 UTC (rev 1071)
@@ -8,20 +8,24 @@
 ?>
 require(nortest)
 
-rk.temp.options <- list (dolength=<? getRK ("length"); ?>, donacount=<? getRK ("nacount"); ?>)
-
 rk.temp.vars <- list (<? echo ($vars); ?>)
-rk.temp.results <- data.frame ('Variable Name'=rep (NA, length (rk.temp.vars)))
+rk.temp.results <- data.frame ('Variable Name'=rep (NA, length (rk.temp.vars)), check.names=FALSE)
 
 i=0;
 for (rk.temp.var in rk.temp.vars) {
 	i = i+1
 	rk.temp.results$'Variable Name'[i] <- rk.get.description (rk.temp.var, is.substitute=TRUE)
-	if (rk.temp.options$dolength) try (rk.temp.results$'Length'[i] <- length (eval (rk.temp.var)))
-	if (rk.temp.options$donacount) try (rk.temp.results$'NAs'[i] <- length (which(is.na(eval (rk.temp.var)))))
-	rk.temp.test <- ad.test (eval (rk.temp.var))
-	rk.temp.results$'Statistic'[i] <- paste (names (rk.temp.test$statistic), rk.temp.test$statistic, sep=" = ")
-	rk.temp.results$'p-value'[i] <- rk.temp.test$p.value
+	<? if (getRK_val ("length")) { ?>
+	try (rk.temp.results$'Length'[i] <- length (eval (rk.temp.var)))
+	<? }
+	if (getRK_val ("nacount")) { ?>
+	try (rk.temp.results$'NAs'[i] <- length (which(is.na(eval (rk.temp.var)))))
+	<? } ?>
+	try ({
+		rk.temp.test <- ad.test (eval (rk.temp.var))
+		rk.temp.results$'Statistic'[i] <- paste (names (rk.temp.test$statistic), rk.temp.test$statistic, sep=" = ")
+		rk.temp.results$'p-value'[i] <- rk.temp.test$p.value
+	})
 }
 
 <?
@@ -39,7 +43,6 @@
 
 ?>
 rm (rk.temp.results)
-rm (rk.temp.options)
 rm (rk.temp.var)
 rm (rk.temp.test)
 <?

Modified: trunk/rkward/rkward/plugins/distributions/ad_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/ad_test.xml	2007-01-07 15:13:15 UTC (rev 1070)
+++ trunk/rkward/rkward/plugins/distributions/ad_test.xml	2007-01-07 15:29:51 UTC (rev 1071)
@@ -12,9 +12,10 @@
 						<varselector id="vars"/>
 					</column>
 					<column>
-						<frame label="The number of the selcted values must be greater than 7">
-							<varslot type="numeric" multi="true" id="x" source="vars" required="true" label="variable(s):"/>
-						</frame>
+						<varslot type="numeric" multi="true" id="x" source="vars" required="true" label="variable(s):" min_length="8"/>
+						<text>
+							Note: Objects must have at least 8 values
+						</text>
 						<stretch/>
 					</column>
 				</row>
@@ -22,6 +23,7 @@
 			<tab label="Options">
 				<checkbox id="length" label="Show Length" value_unchecked="0" value="1" checked="true" />
 				<checkbox id="nacount" label="Show Missing Values" value_unchecked="0" value="1" checked="false" />
+				<stretch/>
 			</tab>
 		</tabbook>
 	</dialog>


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