[rkward-cvs] SF.net SVN: rkward-code:[4869] trunk/rkward/tests

tfry at users.sf.net tfry at users.sf.net
Thu Oct 2 14:44:05 UTC 2014


Revision: 4869
          http://sourceforge.net/p/rkward/code/4869
Author:   tfry
Date:     2014-10-02 14:44:02 +0000 (Thu, 02 Oct 2014)
Log Message:
-----------
Learning to spell, and to assign in .GlobalEnv...

Modified Paths:
--------------
    trunk/rkward/tests/data_plugin_tests.R

Added Paths:
-----------
    trunk/rkward/tests/data_plugin_tests/recode_categorical.messages.txt
    trunk/rkward/tests/data_plugin_tests/recode_categorical.rkcommands.R
    trunk/rkward/tests/data_plugin_tests/recode_categorical.rkout

Removed Paths:
-------------
    trunk/rkward/tests/data_plugin_tests/recode_cateorigal.messages.txt
    trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkcommands.R
    trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkout

Copied: trunk/rkward/tests/data_plugin_tests/recode_categorical.messages.txt (from rev 4867, trunk/rkward/tests/data_plugin_tests/recode_cateorigal.messages.txt)
===================================================================
--- trunk/rkward/tests/data_plugin_tests/recode_categorical.messages.txt	                        (rev 0)
+++ trunk/rkward/tests/data_plugin_tests/recode_categorical.messages.txt	2014-10-02 14:44:02 UTC (rev 4869)
@@ -0,0 +1,2 @@
+Warning in eval(expr, envir, enclos) :
+  Some input values were specified more than once: "9", "10"

Copied: trunk/rkward/tests/data_plugin_tests/recode_categorical.rkcommands.R (from rev 4867, trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkcommands.R)
===================================================================
--- trunk/rkward/tests/data_plugin_tests/recode_categorical.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/data_plugin_tests/recode_categorical.rkcommands.R	2014-10-02 14:44:02 UTC (rev 4869)
@@ -0,0 +1,40 @@
+local ({
+	x <- {e <- warpbreaks[["tension"]]; if (is.factor (e)) {levels (e)} else {sort (unique (e, nmax=10000))}}
+	if (length (x) > 100) x <- c (x[1:100], "____LIMIT____")
+	if (is.character (x)) { op <- options ('useFancyQuotes'=FALSE); x <- dQuote (x); options (op) }
+	x
+})
+local({
+## Compute
+input <- warpbreaks[["tension"]]
+# Use as.character() as intermediate data format, to support adding and dropping levels
+recoded <- as.character (warpbreaks[["tension"]])
+recoded[input == "L"] <- "low"
+recoded[input %in% c("M","H")] <- "midorhigh"
+.GlobalEnv$recoded <- as.factor (recoded)
+## Print result
+rk.header("Recode categorical data", parameters=list("Input variable", "warpbreaks[[\"tension\"]]",
+	"Output variable", "recoded",
+	"Number of differences after recoding", sum (warpbreaks[["tension"]] != recoded, na.rm=TRUE) + sum (is.na (warpbreaks[["tension"]]) != is.na (recoded))))
+})
+local ({
+	x <- {e <- withnas; if (is.factor (e)) {levels (e)} else {sort (unique (e, nmax=10000))}}
+	if (length (x) > 100) x <- c (x[1:100], "____LIMIT____")
+	if (is.character (x)) { op <- options ('useFancyQuotes'=FALSE); x <- dQuote (x); options (op) }
+	x
+})
+local({
+## Compute
+input <- withnas
+recoded <- as.logical ("", length.out = length (withnas))
+recoded[input %in% c("2","3","4","5","6","7","8","9","10")] <- FALSE
+recoded[input %in% c("9","10")] <- NA
+recoded[is.na (input)] <- TRUE
+
+warning ("Some input values were specified more than once: ", "\"9\", \"10\"")
+.GlobalEnv$recoded2 <- recoded
+## Print result
+rk.header("Recode categorical data", parameters=list("Input variable", "withnas",
+	"Output variable", "recoded2",
+	"Number of differences after recoding", sum (withnas != recoded2, na.rm=TRUE) + sum (is.na (withnas) != is.na (recoded2))))
+})

Copied: trunk/rkward/tests/data_plugin_tests/recode_categorical.rkout (from rev 4867, trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkout)
===================================================================
--- trunk/rkward/tests/data_plugin_tests/recode_categorical.rkout	                        (rev 0)
+++ trunk/rkward/tests/data_plugin_tests/recode_categorical.rkout	2014-10-02 14:44:02 UTC (rev 4869)
@@ -0,0 +1,30 @@
+<h1>Recode categorical data</h1>
+<h2>Parameters</h2>
+<ul><li>Input variable: warpbreaks[["tension"]]</li>
+<li>Output variable: recoded</li>
+<li>Number of differences after recoding: 54</li>
+</ul>
+DATE<br />
+
+<p class='character'>
+
+<font class='factor'></p>
+
+<p class='character'>low  low  low  low  low  low  low  low  low  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  low  low  low  low  low  low  low  low  low  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh</p>
+
+<p class='character'></font>
+</p>
+
+<br> 
+
+<p class='character'>Levels:<font class='factorlevels'> low midorhigh</font>
+<br></p>
+<h1>Recode categorical data</h1>
+<h2>Parameters</h2>
+<ul><li>Input variable: withnas</li>
+<li>Output variable: recoded2</li>
+<li>Number of differences after recoding: 20</li>
+</ul>
+DATE<br />
+
+<p class='logical'>NA  FALSE  TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  NA  NA  NA  FALSE  FALSE  FALSE  TRUE  FALSE  FALSE  FALSE  NA  NA</p>

Deleted: trunk/rkward/tests/data_plugin_tests/recode_cateorigal.messages.txt
===================================================================
--- trunk/rkward/tests/data_plugin_tests/recode_cateorigal.messages.txt	2014-10-02 14:21:53 UTC (rev 4868)
+++ trunk/rkward/tests/data_plugin_tests/recode_cateorigal.messages.txt	2014-10-02 14:44:02 UTC (rev 4869)
@@ -1,2 +0,0 @@
-Warning in eval(expr, envir, enclos) :
-  Some input values were specified more than once: "9", "10"

Deleted: trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkcommands.R
===================================================================
--- trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkcommands.R	2014-10-02 14:21:53 UTC (rev 4868)
+++ trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkcommands.R	2014-10-02 14:44:02 UTC (rev 4869)
@@ -1,40 +0,0 @@
-local ({
-	x <- {e <- warpbreaks[["tension"]]; if (is.factor (e)) {levels (e)} else {sort (unique (e, nmax=10000))}}
-	if (length (x) > 100) x <- c (x[1:100], "____LIMIT____")
-	if (is.character (x)) { op <- options ('useFancyQuotes'=FALSE); x <- dQuote (x); options (op) }
-	x
-})
-local({
-## Compute
-input <- warpbreaks[["tension"]]
-# Use as.character() as intermediate data format, to support adding and dropping levels
-recoded <- as.character (warpbreaks[["tension"]])
-recoded[input == "L"] <- "low"
-recoded[input %in% c("M","H")] <- "midorhigh"
-.GlobalEnv$recoded <- as.factor (recoded)
-## Print result
-rk.header("Recode categorical data", parameters=list("Input variable", "warpbreaks[[\"tension\"]]",
-	"Output variable", "recoded",
-	"Number of differences after recoding", sum (warpbreaks[["tension"]] != recoded, na.rm=TRUE) + sum (is.na (warpbreaks[["tension"]]) != is.na (recoded))))
-})
-local ({
-	x <- {e <- withnas; if (is.factor (e)) {levels (e)} else {sort (unique (e, nmax=10000))}}
-	if (length (x) > 100) x <- c (x[1:100], "____LIMIT____")
-	if (is.character (x)) { op <- options ('useFancyQuotes'=FALSE); x <- dQuote (x); options (op) }
-	x
-})
-local({
-## Compute
-input <- withnas
-recoded <- as.logical ("", length.out = length (withnas))
-recoded[input %in% c("2","3","4","5","6","7","8","9","10")] <- FALSE
-recoded[input %in% c("9","10")] <- NA
-recoded[is.na (input)] <- TRUE
-
-warning ("Some input values were specified more than once: ", "\"9\", \"10\"")
-.GlobalEnv$recoded2 <- recoded
-## Print result
-rk.header("Recode categorical data", parameters=list("Input variable", "withnas",
-	"Output variable", "recoded2",
-	"Number of differences after recoding", sum (withnas != recoded2, na.rm=TRUE) + sum (is.na (withnas) != is.na (recoded2))))
-})

Deleted: trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkout
===================================================================
--- trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkout	2014-10-02 14:21:53 UTC (rev 4868)
+++ trunk/rkward/tests/data_plugin_tests/recode_cateorigal.rkout	2014-10-02 14:44:02 UTC (rev 4869)
@@ -1,30 +0,0 @@
-<h1>Recode categorical data</h1>
-<h2>Parameters</h2>
-<ul><li>Input variable: warpbreaks[["tension"]]</li>
-<li>Output variable: recoded</li>
-<li>Number of differences after recoding: 54</li>
-</ul>
-DATE<br />
-
-<p class='character'>
-
-<font class='factor'></p>
-
-<p class='character'>low  low  low  low  low  low  low  low  low  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  low  low  low  low  low  low  low  low  low  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh  midorhigh</p>
-
-<p class='character'></font>
-</p>
-
-<br> 
-
-<p class='character'>Levels:<font class='factorlevels'> low midorhigh</font>
-<br></p>
-<h1>Recode categorical data</h1>
-<h2>Parameters</h2>
-<ul><li>Input variable: withnas</li>
-<li>Output variable: recoded2</li>
-<li>Number of differences after recoding: 20</li>
-</ul>
-DATE<br />
-
-<p class='logical'>NA  FALSE  TRUE  FALSE  FALSE  FALSE  FALSE  FALSE  NA  NA  NA  FALSE  FALSE  FALSE  TRUE  FALSE  FALSE  FALSE  NA  NA</p>

Modified: trunk/rkward/tests/data_plugin_tests.R
===================================================================
--- trunk/rkward/tests/data_plugin_tests.R	2014-10-02 14:21:53 UTC (rev 4868)
+++ trunk/rkward/tests/data_plugin_tests.R	2014-10-02 14:44:02 UTC (rev 4869)
@@ -12,6 +12,7 @@
 			data (warpbreaks)
 			withnas <- sleep$ID
 			withnas[c(3,15)] <- NA
+			assign ("withnas", withnas, envir=.GlobalEnv)
 		}
 	## the tests
 	), tests = list (
@@ -26,7 +27,7 @@
 		new ("RKTest", id="subset_dataframe", call=function () {
 			rk.call.plugin ("rkward::subset_dataframe", drp_fltr_num.string="range", frm_Onlyssbs.checked="1", inp_Exprssnr.text="group == 1", inp_Mnmmrmpt.text="0", inp_Mxmmrmpt.text="3", maxinc.state="0", mininc.state="1", svb_Svrsltst.active="1", svb_Svrsltst.objectname="sset.result", svb_Svrsltst.parent=".GlobalEnv", var_data.available="sleep", vrsl_Fltrbyvr.available="sleep[[\"extra\"]]", vrsl_Slctdvrb.available="sleep[[\"extra\"]]\nsleep[[\"ID\"]]", submit.mode="submit")
 		}),
-		new ("RKTest", id="recode_cateorigal", call=function () {
+		new ("RKTest", id="recode_categorical", call=function () {
 		        rk.call.plugin ("rkward::recode_categorical", datamode.string="factor", other.string="copy", saveto.objectname="recoded", saveto.parent=".GlobalEnv", saveto_select.string="other", set.serialized="_row=new_value.string=custom\tnew_value_custom.input.text=low\told_value_type.string=value\tvalues.available=\\\"L\\\"\n_row=new_value.string=custom\tnew_value_custom.input.text=midorhigh\told_value_type.string=value\tvalues.available=\\\"M\\\"\\n\\\"H\\\"", x.available="warpbreaks[[\"tension\"]]", submit.mode="submit")
 			rk.print (recoded)
 			rm (recoded, envir=.GlobalEnv)
@@ -35,6 +36,6 @@
 			rm (recoded2, envir=.GlobalEnv)
 		})
 	), postCalls = list (
-			function(){rm("women", pos=globalenv())}
+			function(){rm(list=c ("women", "warpbreaks", "withnas"), pos=globalenv())}
 			)	# like initCalls: run after all tests to clean up. Empty in this case.
 )





More information about the rkward-tracker mailing list