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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Jan 7 15:53:39 UTC 2007


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

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

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/distributions/agostino_test.php
    trunk/rkward/rkward/plugins/distributions/agostino_test.xml

Modified: trunk/rkward/rkward/plugins/distributions/agostino_test.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/agostino_test.php	2007-01-07 15:30:12 UTC (rev 1072)
+++ trunk/rkward/rkward/plugins/distributions/agostino_test.php	2007-01-07 15:53:38 UTC (rev 1073)
@@ -5,60 +5,43 @@
 	function calculate () {
 	$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
 
-?>	
+?>
+require(moments)
 
-	require(moments)	
-
-	rk.temp.options <- list (dolength=<? getRK ("length"); ?>, donacount=<? getRK ("nacount"); ?>)
-
-	rk.temp.results <- list ()
-	i=0; for (var in list (<? echo ($vars); ?>)) {
+rk.temp.vars <- list (<? echo ($vars); ?>)
+rk.temp.results <- data.frame ('Variable Name'=rep (NA, length (rk.temp.vars)), check.names=FALSE)
+i=0;
+for (var in rk.temp.vars) {
 	i = i+1
-	rk.temp.results[[i]] <- list ()
-	rk.temp.results[[i]]$object <- rk.get.description (var, is.substitute=TRUE)
-	rk.temp.results[[i]]$agostino <- agostino.test (eval (var), alternative = c("<? getRK ("alternative"); ?>"))
-	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 ("length")) { ?>
+	rk.temp.results$'Length'[i] <- try (length (eval (var)))
+	<? }
+	if (getRK_val ("nacount")) { ?>
+	rk.temp.results$'NAs'[i] <- try (length (which(is.na(eval (var)))))
+	<? } ?>
+	try ({
+		rk.temp.test <- agostino.test (eval (var), alternative = c("<? getRK ("alternative"); ?>"))
+		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
+	})
 
-
+}
 <?
         }
 	function printout () {
-?>	
-	rk.header ("D'Agostino test for skewness in normally distributed data")
-
-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>")
-			cat ("<td>Skewness and Transformation</td>")
-			cat ("<td>p-value</td>")
-			cat ("<td>alternative</td>")
-			cat ("<td>Method</td>")
-			cat ("<td>variable</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>")
-		cat (paste ("<td>", rk.temp.results[[i]]$agostino,"</td>"))
-		cat ("</tr>")
-}
-	cat ("</tbody>")
-cat ("</table>")
-
-
+?>
+rk.header ("D'Agostino test for skewness in normally distributed data")
+rk.results (rk.temp.results)
 <?
         }
 	function cleanup () {
 
 ?>
-	rm (rk.temp.results)
-	rm (rk.temp.options)
-	rm (var)
+rm (rk.temp.results)
+rm (rk.temp.test)
+rm (rk.temp.vars)
+rm (var)
 <?
         }
 ?>
\ No newline at end of file

Modified: trunk/rkward/rkward/plugins/distributions/agostino_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/agostino_test.xml	2007-01-07 15:30:12 UTC (rev 1072)
+++ trunk/rkward/rkward/plugins/distributions/agostino_test.xml	2007-01-07 15:53:38 UTC (rev 1073)
@@ -12,21 +12,17 @@
 						<varselector id="vars"/>
 					</column>
 					<column>
-						<frame label="Variable(s)">
-							<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):"/>
 						<stretch/>
 					</column>
 				</row>
 			</tab>
 			<tab label="Options">
-				<frame>
-					<radio id="alternative" label="alternative hypothesis">
-						<option value="two.sided" label="two sided (default)" />
-						<option value="less" label="less" />
-						<option value="greater" label="greater" />
-					</radio>
-				</frame>
+				<radio id="alternative" label="alternative hypothesis">
+					<option value="two.sided" label="two sided (default)" />
+					<option value="less" label="less" />
+					<option value="greater" label="greater" />
+				</radio>
 				<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" />
 			</tab>


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