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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Jan 7 15:13:16 UTC 2007


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

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

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/code.php
    trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/description.xml
    trunk/rkward/rkward/plugins/00saveload/load/load/code.php
    trunk/rkward/rkward/plugins/00saveload/load/readtable/code.php
    trunk/rkward/rkward/plugins/00saveload/load/source/code.php
    trunk/rkward/rkward/plugins/00saveload/save/save/code.php
    trunk/rkward/rkward/plugins/00saveload/save/skeleton/code.php
    trunk/rkward/rkward/plugins/00saveload/save/write/code.php
    trunk/rkward/rkward/plugins/corr_matrix/code.php

Modified: trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -5,8 +5,9 @@
 	function calculate () {
 ?>rk.temp.x <- substitute (<? getRK ("x"); ?>)
 rk.temp.y <- substitute (<? getRK ("y"); ?>)
-rk.temp.var.equal <- <? getRK ("varequal"); ?> 
-rk.temp <- t.test (eval (rk.temp.x), eval (rk.temp.y), "<? getRK ("hypothesis"); ?>", var.equal=rk.temp.var.equal<?; if (($conflevel = getRK_val ("conflevel")) != "0.95") echo (", conf.level=" . $conflevel); ?>)
+rk.temp <- t.test (eval (rk.temp.x), eval (rk.temp.y), "<? getRK ("hypothesis"); ?>"<?
+if (getRK_val ("varequal")) echo (", var.equal=TRUE");
+if (($conflevel = getRK_val ("conflevel")) != "0.95") echo (", conf.level=" . $conflevel); ?>)
 rk.temp.print.conf.level <- <? if (getRK_val ("confint")) echo "TRUE"; else echo "FALSE"; ?>
 
 <?
@@ -22,21 +23,17 @@
 		paste (rk.get.short.name (rk.temp.x), "is greater than", rk.get.short.name (rk.temp.y))
 	      else
 		paste (rk.get.short.name (rk.temp.x), "and", rk.get.short.name (rk.temp.y), "differ"),
-	"Equal variances:", if (rk.temp.var.equal) "assumed" else "not assumed"))
+	"Equal variances:", "<? if (!getRK_val ("varequal")) echo "not"; ?> assumed"))
 
 rk.results (list (
-	rk.get.description (rk.temp.x),
-	rk.temp$estimate,
-	rk.temp$parameter,
-	rk.temp$statistic,
-	rk.temp$p.value,
-	if (rk.temp.print.conf.level) rk.temp$conf.int),
-	titles=c ("Variable",
-	"estimated mean",
-	"degrees of freedom",
-	"t",
-	"p",
-	if (rk.temp.print.conf.level) paste ("confidence interval of difference (", 100 * attr(rk.temp$conf.int, "conf.level"), "%)")))
+	'Variable Name'=rk.get.description (rk.temp.x),
+	'estimated mean'=rk.temp$estimate,
+	'degrees of freedom'=rk.temp$parameter,
+	t=rk.temp$statistic,
+	p=rk.temp$p.value<?
+	if (getRK_val ("confint")) { ?>,
+	'confidence interval percent'=(100 * attr(rk.temp$conf.int, "conf.level")),
+	'confidence interval of difference'=rk.temp$conf.int <? } ?>))
 <?
 	}
 	

Modified: trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/description.xml
===================================================================
--- trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/description.xml	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00means/00ttests/00independent_samples/description.xml	2007-01-07 15:13:15 UTC (rev 1070)
@@ -22,7 +22,7 @@
 				</row>
 			</tab>
 			<tab label="Options">
-				<checkbox id="varequal" label="assume equal variances" value="TRUE" value_unchecked="FALSE"/>
+				<checkbox id="varequal" label="assume equal variances" value="1" value_unchecked="0"/>
 				<frame label="Confidence Interval">
 					<checkbox id="confint" label="print confidence interval" value="1" checked="true"/>
 					<spinbox type="real" id="conflevel" label="confidence level" min="0" max="1" initial="0.95"/>

Modified: trunk/rkward/rkward/plugins/00saveload/load/load/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/load/load/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00saveload/load/load/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -4,7 +4,7 @@
 	
 	function calculate () {
 ?>
-load(file =  "<? getRK("file") ; ?>" )
+load (file="<? getRK("file"); ?>")
 <?
 	}
 	

Modified: trunk/rkward/rkward/plugins/00saveload/load/readtable/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/load/readtable/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00saveload/load/readtable/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -3,7 +3,7 @@
 	}
 	
 	function calculate () {
-getRK("name") ; ?> <- read.table(file =  "<? getRK("file") ; ?>", header = <? getRK("header") ?>, sep = <? getRK("sep") ?> , dec = <? getRK("dec") ?>, <? # doing row names (what a pity...) 
+getRK("name"); ?> <- read.table (file="<? getRK("file"); ?>", header=<? getRK("header"); ?>, sep=<? getRK("sep"); ?>, dec=<? getRK("dec") ?>, <? # doing row names (what a pity...) 
 if (getRK_val("isrow")=="true") {
 	echo( "row.names = ");
 	if (getRK_val("rowname")=="NULL") echo (getRK_val("rowname") . ",");

Modified: trunk/rkward/rkward/plugins/00saveload/load/source/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/load/source/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00saveload/load/source/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -4,12 +4,11 @@
 	
 	function calculate () {
 ?>
-source ( file =  "<? getRK("file") ; ?>" ,local =  <? getRK("local") ; ?> , echo =  <? getRK("echo") ; ?> , print.eval =  <? getRK("printeval") ; ?> , verbose =  <? getRK("verbose") ; ?> , prompt.echo =   <? getRK("promptecho") ; ?> , max.deparse.length =  <? getRK("maxdeparselength") ; ?> , chdir =  <? getRK("chdir") ; ?> )
+source (file="<? getRK("file"); ?>", local=<? getRK("local"); ?>, echo=<? getRK("echo"); ?>, print.eval= <? getRK("printeval"); ?>, verbose=<? getRK("verbose"); ?>, prompt.echo=<? getRK("promptecho"); ?>, max.deparse.length=<? getRK("maxdeparselength"); ?>, chdir=<? getRK("chdir"); ?>)
 <?
 	}
 	
 	function printout () {
-	// produce the output
 	}
 	
 	function cleanup () {

Modified: trunk/rkward/rkward/plugins/00saveload/save/save/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00saveload/save/save/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -5,12 +5,11 @@
 	function calculate () {
 $vars = str_replace ("\n", ",", trim (getRK_val ("data"))) ;
 ?>
-save ( <? echo ($vars) ; ?> , file =  "<? getRK("file") ; ?>" , ascii =  <? getRK("ascii") ; ?> , compress =  <? getRK("compress") ; ?> )
+save (<? echo ($vars); ?>, file="<? getRK("file"); ?>", ascii=<? getRK("ascii"); ?>, compress=<? getRK("compress"); ?>)
 <?
 	}
 	
 	function printout () {
-	// produce the output
 	}
 	
 	function cleanup () {

Modified: trunk/rkward/rkward/plugins/00saveload/save/skeleton/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/skeleton/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00saveload/save/skeleton/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -5,12 +5,11 @@
 	function calculate () {
 $vars = str_replace ("\n", "','", trim (getRK_val ("data"))) ;
 ?>
-package.skeleton(name =  "<? getRK("name") ; ?>", list = c('<? echo ($vars) ; ?>'),  path = "<? getRK("path") ; ?>", force =  "<? getRK("force") ; ?>")
+package.skeleton(name="<? getRK("name"); ?>", list=c('<? echo ($vars); ?>'), path="<? getRK("path"); ?>", force= "<? getRK("force"); ?>")
 <?
 	}
 	
 	function printout () {
-	// produce the output
 	}
 	
 	function cleanup () {

Modified: trunk/rkward/rkward/plugins/00saveload/save/write/code.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/write/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/00saveload/save/write/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -4,12 +4,11 @@
 	
 	function calculate () {
 ?>
-write ( x =  <? getRK("data") ; ?> , file =  "<? getRK("file") ; ?>" , ncolumns =  <? getRK("ncolumns") ; ?> , append =  <? getRK("append") ; ?> )
+write (x=<? getRK("data"); ?>, file="<? getRK("file"); ?>", ncolumns=<? getRK("ncolumns"); ?>, append=<? getRK("append"); ?>)
 <?
 	}
 	
 	function printout () {
-	// produce the output
 	}
 	
 	function cleanup () {

Modified: trunk/rkward/rkward/plugins/corr_matrix/code.php
===================================================================
--- trunk/rkward/rkward/plugins/corr_matrix/code.php	2007-01-05 14:06:04 UTC (rev 1069)
+++ trunk/rkward/rkward/plugins/corr_matrix/code.php	2007-01-07 15:13:15 UTC (rev 1070)
@@ -6,37 +6,21 @@
 		$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
 
 ?>rk.temp.objects <- list (<? echo ($vars); ?>)
-rk.temp.options <- list (method="<? getRK ("method"); ?>", use="<? getRK ("use"); ?>")
 
-rk.temp.frame <- list ()
-for (i in 1:length (rk.temp.objects)) rk.temp.frame[[i]] <- eval (rk.temp.objects[[i]])
-rk.temp.frame <- data.frame (rk.temp.frame)
+# cor requires all object to be inside the same data.frame.
+# Here we construct such a temporary frame from the input variables
+rk.temp.frame <- data.frame (lapply (rk.temp.objects, eval))
 
-rk.temp <- cor (rk.temp.frame, use=rk.temp.options$use, method=rk.temp.options$method)
+rk.temp <- cor (rk.temp.frame, use="<? getRK ("use"); ?>", method="<? getRK ("method"); ?>")
 <?
 	}
 	
 	function printout () {
 ?>
-rk.temp <- as.data.frame (rk.temp)
+rk.header ("Correlation Matrix", parameters=list ("Method", "<? getRK ("method"); ?>", "Exclusion", "<? getRK ("use"); ?>"))
+rk.temp <- data.frame (I (sapply (rk.temp.objects, FUN=function (x) { rk.get.description (x, is.substitute=TRUE)})), as.data.frame (rk.temp))
 
-cat ("<h1>Correlation Matrix</h1>")
-cat (paste ("<h2>TODO: describe in verbatim:", rk.temp.options$method, rk.temp.options$use, "</h2>"))
-
-cat ("<table border=\"1\">\n<tr>\n<td>Variable</td>")
-for (i in 1:dim (rk.temp)[2]) {
-	cat (paste ("<td>", rk.get.short.name (rk.temp.objects[[i]]), "</td>"))
-}
-cat ("</tr>\n")
-
-for (i in 1:dim (rk.temp)) {
-	cat (paste ("<tr><td>", rk.get.description (rk.temp.objects[[i]]), "</td>"))
-	for (j in 1:dim (rk.temp)) {
-		cat (paste ("<td>", rk.temp[i,j], "</td>"))
-	}
-	cat ("</tr>\n")
-}
-cat ("</table>")
+rk.results (rk.temp, titles=c ('Variable Name', sapply (rk.temp.objects, rk.get.short.name)))
 <?
 	}
 	


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