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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Feb 25 21:55:56 UTC 2010


Revision: 2756
          http://rkward.svn.sourceforge.net/rkward/?rev=2756&view=rev
Author:   tfry
Date:     2010-02-25 21:55:54 +0000 (Thu, 25 Feb 2010)

Log Message:
-----------
Convert first bunch of analysis plugins to JS

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.js
    trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.xml
    trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.js
    trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.xml
    trunk/rkward/rkward/plugins/analysis/corr_matrix.js
    trunk/rkward/rkward/plugins/analysis/corr_matrix.xml
    trunk/rkward/rkward/plugins/analysis/crosstab.js
    trunk/rkward/rkward/plugins/analysis/crosstab.xml
    trunk/rkward/rkward/plugins/analysis/crosstab_multi.js
    trunk/rkward/rkward/plugins/analysis/crosstab_multi.xml
    trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js
    trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml
    trunk/rkward/rkward/plugins/uni1.2/code.js
    trunk/rkward/rkward/plugins/uni1.2/description.xml

Removed Paths:
-------------
    trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.php
    trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.php
    trunk/rkward/rkward/plugins/analysis/corr_matrix.php
    trunk/rkward/rkward/plugins/analysis/crosstab.php
    trunk/rkward/rkward/plugins/analysis/crosstab_multi.php
    trunk/rkward/rkward/plugins/analysis/t_test_two_vars.php
    trunk/rkward/rkward/plugins/uni1.2/code.php

Modified: trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,13 +1,3 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
 function preprocess () {
 	echo ('require(exactRankTests)\n');
 	echo ('\n');
@@ -15,18 +5,18 @@
 }
 
 function calculate () {
-	var exact_setting = "";
 	var exact_opt = "";
-	var conflevel = "";
-	var conflevel_opt = "";
-	exact_setting = getValue ("exact");
+	var exact_setting = getValue ("exact");
 	if (exact_setting == "yes") {
 		exact_opt = ", exact=TRUE";
 	} else if (exact_setting == "no") {
 		exact_opt = ", exact=FALSE";
 	}
+
+	var conflevel_opt = "";
 	if (getValue ("confint") == "TRUE") {
-		if ((conflevel = getValue("conflevel")) != "0.95") conflevel_opt = ", conf.level=" + conflevel;
+		var conflevel = getValue("conflevel");
+		if (conflevel != "0.95") conflevel_opt = ", conf.level=" + conflevel;
 	}
 
 	echo ('result <- ansari.exact (' + getValue ("x") + ', ' + getValue ("y") + ', alternative = "' + getValue ("alternative") + '"' + exact_opt + ', conf.int = ' + getValue ("confint") + conflevel_opt + ')\n');

Deleted: trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,44 +0,0 @@
-<?
-function preprocess () { ?>
-require(exactRankTests)
-
-names <- rk.get.description (<? getRK ("x"); ?>, <? getRK ("y"); ?>)
-<?
-}
-
-function calculate () {
-	$exact_setting = getRK_val ("exact");
-	if ($exact_setting == "yes") {
-		$exact_opt = ", exact=TRUE";
-	} else if ($exact_setting == "no") {
-		$exact_opt = ", exact=FALSE";
-	}
-	if (getRK_val ("confint") == "TRUE") {
-		if (($conflevel = getRK_val("conflevel")) != "0.95") $conflevel_opt = ", conf.level=" . $conflevel;
-	}
-?>
-result <- ansari.exact (<? getRK ("x"); ?>, <? getRK ("y"); ?>, alternative = "<? getRK ("alternative"); ?>"<? echo ($exact_opt); ?>, conf.int = <? getRK ("confint"); echo ($conflevel_opt); ?>)
-
-<?
-}
-
-function printout () {
-?>
-rk.header (result$method,
-	parameters=list ("Comparing", paste (names[1], "against", names[2]),
-	'H1', rk.describe.alternative (result),
-	"Compute exact p-value", "<? getRK ("exact"); ?>"<? if (getRK_val ("confint")== "TRUE") {?>,
-	"Confidence Level", "<? getRK ("conflevel"); ?>" <?}?>))
-
-rk.results (list (
-	'Variable Names'=names,
-	'statistic'=result$statistic,
-	'null.value'=result$null.value,
-	p=result$p.value<?
-	if (getRK_val ("confint")== "TRUE") { ?>,
-	'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
-	'confidence interval of difference'=result$conf.int,
-	'estimate of the ratio of scales'=result$estimate<? } ?>))
-<?
-}
-?>

Modified: trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_exact_test.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="ansari_bradley_exact_test.php"/>
+	<code file="ansari_bradley_exact_test.js"/>
 	<help file="ansari_bradley_exact_test.rkh"/>
 
 	<logic>

Modified: trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,30 +1,20 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
 function preprocess () {
 	echo ('names <- rk.get.description (' + getValue ("x") + ', ' + getValue ("y") + ')\n');
 }
 
 function calculate () {
-	var exact_setting = "";
 	var exact_opt = "";
-	var conflevel = "";
-	var conflevel_opt = "";
-	exact_setting = getValue ("exact");
+	var exact_setting = getValue ("exact");
 	if (exact_setting == "yes") {
 		exact_opt = ", exact=TRUE";
 	} else if (exact_setting == "no") {
 		exact_opt = ", exact=FALSE";
 	}
+
+	var conflevel_opt = "";
 	if (getValue ("confint") == "TRUE") {
-		if ((conflevel = getValue("conflevel")) != "0.95") conflevel_opt = ", conf.level=" + conflevel;
+		var conflevel = getValue("conflevel");
+		if (conflevel != "0.95") conflevel_opt = ", conf.level=" + conflevel;
 	}
 
 	echo ('result <- ansari.test (' + getValue ("x") + ', ' + getValue ("y") + ', alternative = "' + getValue ("alternative") + '"' + exact_opt + ', conf.int = ' + getValue ("confint") + conflevel_opt + ')\n');

Deleted: trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,43 +0,0 @@
-<?
-function preprocess () { ?>
-names <- rk.get.description (<? getRK ("x"); ?>, <? getRK ("y"); ?>)
-<?
-}
-
-function calculate () {
-	$exact_setting = getRK_val ("exact");
-	if ($exact_setting == "yes") {
-		$exact_opt = ", exact=TRUE";
-	} else if ($exact_setting == "no") {
-		$exact_opt = ", exact=FALSE";
-	}
-	if (getRK_val ("confint") == "TRUE") {
-		if (($conflevel = getRK_val("conflevel")) != "0.95") $conflevel_opt = ", conf.level=" . $conflevel;
-	}
-?>
-result <- ansari.test (<? getRK ("x"); ?>, <? getRK ("y"); ?>, alternative = "<? getRK ("alternative"); ?>"<? echo ($exact_opt); ?>, conf.int = <? getRK ("confint"); echo ($conflevel_opt); ?>)
-
-<?
-}
-
-function printout () {
-?>
-rk.header (result$method,
-	parameters=list (
-		"Comparing", paste (names[1], "against", names[2]),
-		"Alternative Hypothesis", rk.describe.alternative(result),
-		"Compute exact p-value", "<? getRK ("exact"); ?>"<? if (getRK_val ("confint")== "TRUE") {?>,
-		 "Confidence Level", "<? getRK ("conflevel"); ?>" <?}?>))
-
-rk.results (list (
-	'Variable Names'=names,
-	'statistic'=result$statistic,
-	'null.value'=result$null.value,
-	p=result$p.value<?
-	if (getRK_val ("confint")== "TRUE") { ?>,
-	'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
-	'confidence interval of difference'=result$conf.int,
-	'estimate of the ratio of scales'=result$estimate<? } ?>))
-<?
-}
-?>

Modified: trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/ansari_bradley/ansari_bradley_test.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="ansari_bradley_test.php"/>
+	<code file="ansari_bradley_test.js"/>
 	<help file="ansari_bradley_test.rkh"/>
 
 	<logic>

Modified: trunk/rkward/rkward/plugins/analysis/corr_matrix.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/corr_matrix.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/corr_matrix.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,22 +1,13 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-
----------------------------- */
-
 // globals
 var use;
 var method;
 var do_p;
-var undefined;
 
-
 function calculate () {
-	var vars = "";
-	var exclude_whole = "";
 	do_p = getValue ("do_p");
 
-	vars = "substitute (" + str_replace ("\n", "), substitute (", trim (getValue ("x"))) + ")";
+	var exclude_whole = "";
+	var vars = "substitute (" + str_replace ("\n", "), substitute (", trim (getValue ("x"))) + ")";
 	use = getValue ("use");
 	if (use == "pairwise") {
 		exclude_whole = false;

Deleted: trunk/rkward/rkward/plugins/analysis/corr_matrix.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/corr_matrix.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/corr_matrix.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,67 +0,0 @@
-<?
-function preprocess () {
-}
-	
-function calculate () {
-	global $use;
-	global $method;
-	global $do_p;
-
-	$do_p = getRK_val ("do_p");
-
-	$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("x"))) . ")";
-	$use = getRK_val ("use");
-	if ($use == "pairwise") {
-		$exclude_whole = false;
-		$use = "\"pairwise.complete.obs\"";
-	} else {
-		$exclude_whole = true;
-		$use = "\"complete.obs\"";
-	}
-	$method = "\"" . getRK_val ("method") . "\"";
-
-?>objects <- list (<? echo ($vars); ?>)
-
-# cor requires all objects to be inside the same data.frame.
-# Here we construct such a temporary frame from the input variables
-data <- data.frame (lapply (objects, function (x) eval (x, envir=globalenv ())))
-
-# calculate correlation matrix
-result <- cor (data, use=<? echo ($use); ?>, method=<? echo ($method); ?>)
-<?	if ($do_p) { ?>
-# calculate matrix of probabilities
-result.p <- matrix (nrow = length (data), ncol = length (data))
-<?		if ($exclude_whole) { ?>
-# as we need to do pairwise comparisons for technical reasons,
-# we need to exclude incomplete cases first to match the use="complete.obs" parameter to cor()
-data <- data[complete.cases (data),]
-<?		} ?>
-for (i in 1:length (data)) {
-	for (j in i:length (data)) {
-		if (i != j) {
-			t <- cor.test (data[[i]], data[[j]], method=<? echo ($method); ?>)
-			result.p[i, j] <- t$p.value
-			result.p[j, i] <- sum (complete.cases (data[[i]], data[[j]]))
-		}
-	}
-}
-<?	}
-}
-
-function printout () {
-	global $use;
-	global $method;
-	global $do_p;
-?>
-rk.header ("Correlation Matrix", parameters=list ("Method", <? echo ($method); ?>, "Exclusion", <? echo ($use); ?>))
-
-result <- data.frame (I (sapply (objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (result))
-rk.results (result, titles=c ('Coefficient', sapply (objects, rk.get.short.name)))
-
-<?	if ($do_p) { ?>
-result.p <- data.frame (I (sapply (objects, FUN=function (x) rk.get.description (x, is.substitute=TRUE))), as.data.frame (result.p))
-rk.results (result.p, titles=c ('n \\ p', sapply (objects, rk.get.short.name)))
-<?	}
-}
-
-?>

Modified: trunk/rkward/rkward/plugins/analysis/corr_matrix.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/corr_matrix.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/corr_matrix.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,7 +1,7 @@
 <!DOCTYPE rkplugin>
 
 <document>
-	<code file="corr_matrix.php"/>
+	<code file="corr_matrix.js"/>
 	<help file="corr_matrix.rkh"/>
 
 	<dialog label="Correlation matrix">

Modified: trunk/rkward/rkward/plugins/analysis/crosstab.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/crosstab.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/crosstab.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,18 +1,6 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-
----------------------------- */
-
-// globals
-var undefined;
-
-
 function calculate () {
-	var x = "";
-	var y = "";
-	x = getValue ("x") ;
-	y = "substitute (" + str_replace ("\n", "), substitute (", trim (getValue ("y"))) + ")";
+	var x = getValue ("x") ;
+	var y = "substitute (" + trim (getValue ("y")).replace (/\n/g, "), substitute (") + ")";
 
 	echo ('x <- ' + x + "\n");
 	echo ('yvars <- list (' + y + ')\n');
@@ -48,7 +36,6 @@
 }
 
 function preview () {
-	preprocess ();
 	calculate ();
 	doPrintout (false);
 }
@@ -76,9 +63,9 @@
 		}
 		echo ('}\n');
 	} else {
-		// produce a single barplot of the first result ?>
-		i <- 1
-		<? echo (getValue ('barplot_embed.code.printout'));
+		// produce a single barplot of the first result
+		echo ("i <- 1\n");
+		echo (getValue ('barplot_embed.code.printout'));
 	}
 
 }

Deleted: trunk/rkward/rkward/plugins/analysis/crosstab.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/crosstab.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/crosstab.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,72 +0,0 @@
-<?
-function preprocess () {
-}
-	
-function calculate () {
-	$x = getRK_val ("x") ;
-	$y = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("y"))) . ")";
-?>
-x <- <? echo ($x . "\n"); ?>
-yvars <- list (<? echo ($y); ?>)
-results <- list()
-descriptions <- list ()
-
-# calculate crosstabs
-for (i in 1:length (yvars)) {
-	yvar <- eval (yvars[[i]], envir=globalenv ())
-	results[[i]] <- table(x, yvar)
-
-	descriptions[[i]] <- list ('Dependent'=rk.get.description (<? echo ($x); ?>), 'Independent'=rk.get.description (yvars[[i]], is.substitute=TRUE))
-}
-<?
-	if (getRK_val ("chisq") == "TRUE") { ?>
-
-# calculate chisquares
-chisquares <- list ()
-for (i in 1:length (results)) {
-	chisquares[[i]] <- chisq.test (results[[i]], simulate.p.value = <? getRK ("simpv");?><?if (getRK_val ("simpv") == "TRUE") { ?>,B=(<? getRK ("B"); ?>) <?}?>)
-}
-<?	}
-
-}
-
-function printout () {
-	doPrintout (true);
-}
-
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	if ($final) { ?>
-rk.header ("Crosstabs (n to 1)", level=1)
-for (i in 1:length (results)) {
-	rk.header ("Crosstabs (n to 1)", parameters=list ("Dependent", descriptions[[i]][['Dependent']], "Independent", descriptions[[i]][['Independent']]), level=2)
-	rk.results (results[[i]], titles=c(descriptions[[i]][['Dependent']], descriptions[[i]][['Independent']]))
-<?		if (getRK_val ("chisq") == "TRUE") { ?>
-
-	rk.header ("Pearson's Chi Square Test for Crosstabs", list ("Dependent", descriptions[[i]][['Dependent']], "Independent", descriptions[[i]][['Independent']], "Method", chisquares[[i]][["method"]]), level=2)
-	rk.results (list ('Statistic'=chisquares[[i]][['statistic']], 'df'=chisquares[[i]][['parameter']], 'p'=chisquares[[i]][['p.value']]))
-<?		}
-
-		if (getRK_val ("barplot") == "TRUE") { ?>
-
-	rk.header ("Barplot for Crosstabs", list ("Dependent", descriptions[[i]][['Dependent']], "Independent", descriptions[[i]][['Independent']]<? getRK ('barplot_embed.code.preprocess'); ?>), level=2)
-	rk.graph.on ()
-	try ({
-<?			printIndented ("\t\t", getRK_val ('barplot_embed.code.printout')); ?>
-	})
-	rk.graph.off ()
-<?		} ?>
-}
-<?	} else {
-		// produce a single barplot of the first result ?>
-i <- 1
-<? getRK ('barplot_embed.code.printout'); ?>
-<?	}
-
-}
-?>

Modified: trunk/rkward/rkward/plugins/analysis/crosstab.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/crosstab.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/crosstab.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="crosstab.php"/>
+	<code file="crosstab.js"/>
 	<help file="crosstab.rkh"/>
 	<logic>
 		<connect client="chi_options.enabled" governor="chisq.state" />

Modified: trunk/rkward/rkward/plugins/analysis/crosstab_multi.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/crosstab_multi.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/crosstab_multi.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,16 +1,5 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
 function preprocess () {
-	var vars = "";
-	vars = str_replace ("\n", ",", trim (getValue ("x"))) ;
+	var vars = trim (getValue ("x")).replace (/\n/g, ",");
 
 	echo ('data <- data.frame (' + vars + ', check.names=FALSE)\n');
 	echo ('datadescription <- paste (rk.get.description (' + vars + '), collapse=", ");\n');

Deleted: trunk/rkward/rkward/plugins/analysis/crosstab_multi.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/crosstab_multi.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/crosstab_multi.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,23 +0,0 @@
-<?
-function preprocess () {
-$vars = str_replace ("\n", ",", trim (getRK_val ("x"))) ;
-?>
-data <- data.frame (<? echo ($vars); ?>, check.names=FALSE)
-datadescription <- paste (rk.get.description (<? echo ($vars); ?>), collapse=", ");
-<?
-}
-
-function calculate () {
-?>
-result <- ftable (data<? if (!getRK_val ("exclude_nas.state")) echo (", exclude=NULL"); ?>);
-<?
-}
-
-function printout () {
-?>
-rk.header ("Crosstabs (n to n)", parameters=list ("Variables"=datadescription))
-
-rk.print (result)
-<?
-}
-?>

Modified: trunk/rkward/rkward/plugins/analysis/crosstab_multi.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/crosstab_multi.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/crosstab_multi.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="crosstab_multi.php" />
+	<code file="crosstab_multi.js" />
 	<help file="crosstab_multi.rkh" />
 
 	<dialog label="N to N Crosstabulation" >

Modified: trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/t_test_two_vars.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,19 +1,8 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
 // globals
 var x;
 var y;
 var varequal;
 var paired;
-var undefined;
 
 function preprocess () {
 	x = getValue ("x");
@@ -23,15 +12,13 @@
 }
 
 function calculate () {
-	var conflevel = "";
-	var hypothesis = "";
-	var options = "";
-	conflevel = getValue ("conflevel");
 	varequal = getValue ("varequal");
 	paired = getValue ("paired");
-	hypothesis = getValue ("hypothesis");
 
-	options = ", alternative=\"" + hypothesis + "\"";
+	var conflevel = getValue ("conflevel");
+	var hypothesis = getValue ("hypothesis");
+
+	var options = ", alternative=\"" + hypothesis + "\"";
 	if (paired) options += ", paired=TRUE";
 	if ((!paired) && varequal) options += ", var.equal=TRUE";
 	if (conflevel != "0.95") options += ", conf.level=" + conflevel;

Deleted: trunk/rkward/rkward/plugins/analysis/t_test_two_vars.php
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test_two_vars.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/t_test_two_vars.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,57 +0,0 @@
-<?
-function preprocess () {
-	global $x;
-	global $y;
-
-	$x = getRK_val ("x");
-	$y = getRK_val ("y");
-?>
-names <- rk.get.description (<? echo ($x . ", " . $y); ?>)
-<?
-}
-
-function calculate () {
-	global $x;
-	global $y;
-	global $varequal;
-	global $paired;
-
-	$conflevel = getRK_val ("conflevel");
-	$varequal = getRK_val ("varequal");
-	$paired = getRK_val ("paired");
-	$hypothesis = getRK_val ("hypothesis");
-
-	$options = ", alternative=\"" . $hypothesis . "\"";
-	if ($paired) $options .= ", paired=TRUE";
-	if ((!$paired) && $varequal) $options .= ", var.equal=TRUE";
-	if ($conflevel != "0.95") $options .= ", conf.level=" . $conflevel;
-?>
-result <- t.test (<? echo ($x . ", " . $y . $options); ?>)
-<?
-}
-
-function printout () {
-	global $varequal;
-	global $paired;
-?>
-rk.header (result$method, 
-	parameters=list ("Comparing", paste (names[1], "against", names[2]),
-	"H1", rk.describe.alternative (result)<?
-	if (!$paired) { ?>
-,
-	"Equal variances", "<? if (!$varequal) echo ("not"); ?> assumed"<?
-	} ?>))
-
-rk.results (list (
-	'Variable Name'=names,
-	'estimated mean'=result$estimate,
-	'degrees of freedom'=result$parameter,
-	t=result$statistic,
-	p=result$p.value<?
-	if (getRK_val ("confint")) { ?>,
-	'confidence interval percent'=(100 * attr(result$conf.int, "conf.level")),
-	'confidence interval of difference'=result$conf.int <? } ?>))
-<?
-}
-
-?>

Modified: trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml
===================================================================
--- trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/analysis/t_test_two_vars.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,6 +1,6 @@
 <!DOCTYPE rkplugin>
 <document>
-	<code file="t_test_two_vars.php"/>
+	<code file="t_test_two_vars.js"/>
 	<help file="t_test_two_vars.rkh"/>
 
 	<logic>

Modified: trunk/rkward/rkward/plugins/uni1.2/code.js
===================================================================
--- trunk/rkward/rkward/plugins/uni1.2/code.js	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/uni1.2/code.js	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,27 +1,8 @@
-/* ------- This file generated by php2js from PHP code. --------
-Please check this file by hand, and remove this notice, afterwards.
-Messages:
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-Note: Control statement without braces. This is bad style.
-
----------------------------- */
-
-// globals
-var undefined;
-
-
 function calculate () {
-	var vars = "";
-	var narm = "";
-	var name = "";
-	var nmin = "";
-	var nmax = "";
-	var nautre = "";
-	vars = "substitute (" + str_replace ("\n", "), substitute (", trim (getValue ("z"))) + ")";
+	var vars = "substitute (" + trim (getValue ("z")).replace (/\n/g, "), substitute (") + ")";
+
+	var narm = "na.rm=FALSE";
 	if (getValue ("narm")) narm = "na.rm=TRUE";
-	else name = "na.rm=FALSE";
 
 	echo ('vars <- list (' + vars + ')\n');
 	echo ('results <- data.frame (\'Variable Name\'=rep (NA, length (vars)), check.names=FALSE)\n');
@@ -49,11 +30,13 @@
 	if (getValue ("maximum")) {
 		echo ('	results[i, \'Maximum\'] <- max(var,' + narm + ')\n');
 	}
+	var nmin;
 	if ((nmin = getValue ("nbminimum")) != "0") {
 		echo ('	if (length (var) >= ' + nmin + ') {\n');
 		echo ('		results[i, \'Minimum values\'] <- paste (sort(var, decreasing=FALSE, na.last=TRUE)[1:' + nmin + '], collapse=" ")\n');
 		echo ('	}\n');
 	}
+	var nmax;
 	if ((nmax = getValue ("nbmaximum")) != "0") {
 		echo ('	if (length (var) >= ' + nmax + ') {\n');
 		echo ('		results[i, \'Maximum values\'] <- paste (sort(var, decreasing=TRUE, na.last=TRUE)[1:' + nmax + '], collapse=" ")\n');
@@ -69,6 +52,7 @@
 		echo ('	temp <- quantile (var,' + narm + ')\n');
 		echo ('	results[i, \'Quartiles\'] <- paste (names (temp), temp, sep=": ", collapse=" ")\n');
 	}
+	var nautre;
 	if ((nautre = getValue ("autre")) != "0") {
 		echo ('	temp <- quantile (var, probs=seq (0, 1, length.out=' + nautre + '), ' + narm + ')\n');
 		echo ('	results[i, \'Quantiles\'] <- paste (names (temp), temp, sep=": ", collapse=" ")\n');
@@ -88,7 +72,7 @@
 		echo ('		temp <- hubers (var, k = ' + getValue ("winsor") + ',tol=' + getValue ("tol"));
 		if (getValue("customMu")=="1") echo (", mu="+getValue("mu"));
 		if (getValue("customS")=="1") echo (", s="+getValue("s"));
-		echo (",initmu ="+getValue("initmu")+"(var)") echo (')\n');
+		echo (",initmu ="+getValue("initmu")+"(var))\n");
 		echo ('	})\n');
 		echo ('	results[i, \'Huber M-Estimator\'] <- paste (temp[[1]], temp[[2]], sep=": ", collapse=" ")\n');
 	}

Deleted: trunk/rkward/rkward/plugins/uni1.2/code.php
===================================================================
--- trunk/rkward/rkward/plugins/uni1.2/code.php	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/uni1.2/code.php	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,114 +0,0 @@
-<?
-function preprocess () {
-}
-
-function calculate () {
-$vars = "substitute (" . str_replace ("\n", "), substitute (", trim (getRK_val ("z"))) . ")";
-if (getRK_val ("narm")) $narm = "na.rm=TRUE";
-else $name = "na.rm=FALSE";
-?>
-vars <- list (<? echo ($vars); ?>)
-results <- data.frame ('Variable Name'=rep (NA, length (vars)), check.names=FALSE)
-
-for (i in 1:length (vars))  {
-	var <- eval (vars[[i]], envir=globalenv());
-	results[i, 'Variable Name'] <- rk.get.description(vars[[i]], is.substitute=TRUE)
-
-<?	if (getRK_val ("length")) { ?>
-	results[i, 'Number of obs'] <- length(var)
-	results[i, 'Number of missing values'] <- sum(is.na(var))
-<?	}
-	if (getRK_val ("mean")) { ?>
-	results[i, 'Mean'] <- mean(var,<? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("vari")) { ?>
-	results[i, 'Variance'] <- var(var,<? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("sd")) { ?>
-	results[i, 'Sd'] <- sd(var,<? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("minimum")) { ?>
-	results[i, 'Minimum'] <- min(var,<? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("maximum")) { ?>
-	results[i, 'Maximum'] <- max(var,<? echo ($narm); ?>)
-<?	}
-	if (($nmin = getRK_val ("nbminimum")) != "0") { ?>
-	if (length (var) >= <? echo ($nmin); ?>) {
-		results[i, 'Minimum values'] <- paste (sort(var, decreasing=FALSE, na.last=TRUE)[1:<? echo ($nmin); ?>], collapse=" ")
-	}
-<? 	}
-	if (($nmax = getRK_val ("nbmaximum")) != "0") { ?>
-	if (length (var) >= <? echo ($nmax); ?>) {
-		results[i, 'Maximum values'] <- paste (sort(var, decreasing=TRUE, na.last=TRUE)[1:<? echo ($nmax); ?>], collapse=" ")
-	}
-<? 	}
-	if (getRK_val ("median")) { ?>
-	results[i, 'Median'] <- median(var,<? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("irq")) { ?>
-	results[i, 'Inter Quartile Range'] <- IQR(var,<? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("quartile")) { ?>
-	temp <- quantile (var,<? echo ($narm); ?>)
-	results[i, 'Quartiles'] <- paste (names (temp), temp, sep=": ", collapse=" ")
-<?	}
-	if (($nautre = getRK_val ("autre")) != "0") { ?>
-	temp <- quantile (var, probs=seq (0, 1, length.out=<? echo ($nautre); ?>), <? echo ($narm); ?>)
-	results[i, 'Quantiles'] <- paste (names (temp), temp, sep=": ", collapse=" ")
-<?	} ?>
-	
-	#robust statistics
-<?	if (getRK_val ("trim") == "1") { ?>
-	results[i, 'Trimmed Mean'] <- mean (var, trim=<? getRK ("pourcent"); ?>, <? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("mad") == "1") { ?>
-	results[i, 'Median Absolute Deviation'] <- mad (var, constant=<? getRK ("constMad"); ?>, <? echo ($narm); ?>)
-<?	}
-	if (getRK_val ("huber") == "1") { ?>
-	require ("MASS")
-	temp <- list (c('Location Estimate','Mad scale estimate'), c(NA,NA))
-	try({
-		temp <- hubers (var, k = <? getRK ("winsor"); ?>,tol=<? getRK ("tol"); ?><?
-	if (getRK_val("customMu")=="1") echo (", mu=".getRK_val("mu"));
-	if (getRK_val("customS")=="1") echo (", s=".getRK_val("s"));
-	echo (",initmu =".getRK_val("initmu")."(var)") ?>)
-	})
-	results[i, 'Huber M-Estimator'] <- paste (temp[[1]], temp[[2]], sep=": ", collapse=" ")
-<?	} ?>
-}
-
-<?	if (getRK_val ("result") == "1") { ?>
-# store results
-'<? getRK ("nom"); ?>' <- results
-<?	} ?>
-<?
-}
-
-function printout () {
-?>
-rk.header ("Univariate statistics", parameters=list (
-"Remove Missing values", <? if (getRK_val ("narm")) echo ("TRUE"); else echo ("FALSE"); ?>
-<?	if (getRK_val("trim")=="1") { ?>
-, "Trimmed value for trimmed mean", "<? getRK ("pourcent"); ?>"
-<?	}
-	if (getRK_val("mad")=="1") { ?>
-, "Constant for the MAD estimation", "<? getRK ("constMad"); ?>"
-<?	}
-	if (getRK_val("huber")=="1") { ?>
-, "Winsorized values for Huber estimator", "<? getRK ("winsor"); ?>"
-, "Tolerance in Huber estimator", "<? getRK ("tol"); ?>"
-<?		if (getRK_val ("customMu")=="1") { ?>
-, "Mu for Huber estimator", "<? getRK ("mu"); ?>"
-<?		}
-		if (getRK_val ("customS")=="1") { ?>
-, "S for Huber estimator", "<? getRK ("s"); ?>"
-<?		} ?>
-, "Initial value", "<? getRK ("initmu"); ?>"
-<?	} ?>
-))
-
-rk.results (results)
-<?
-}
-?>

Modified: trunk/rkward/rkward/plugins/uni1.2/description.xml
===================================================================
--- trunk/rkward/rkward/plugins/uni1.2/description.xml	2010-02-25 21:29:09 UTC (rev 2755)
+++ trunk/rkward/rkward/plugins/uni1.2/description.xml	2010-02-25 21:55:54 UTC (rev 2756)
@@ -1,7 +1,7 @@
 <!DOCTYPE rkplugin>
 <!-- TODO: This plugin should really be split up. It is overly complex. -->
 <document>
-	<code file="code.php"/>
+	<code file="code.js"/>
 	<logic>
 		<connect client="constMad.enabled" governor="mad.state" />
 		<connect client="pourcent.enabled" governor="trim.state" />


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