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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Tue Aug 11 13:22:42 UTC 2009


Revision: 2608
          http://rkward.svn.sourceforge.net/rkward/?rev=2608&view=rev
Author:   tfry
Date:     2009-08-11 13:22:41 +0000 (Tue, 11 Aug 2009)

Log Message:
-----------
Add test for import_spss

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

Added Paths:
-----------
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.messages.txt
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkcommands.R
    trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkout
    trunk/rkward/tests/import_export_plugins_testfile.sav

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.messages.txt
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.messages.txt	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.messages.txt	2009-08-11 13:22:41 UTC (rev 2608)
@@ -0,0 +1,3 @@
+Warning message:
+In read.spss("../import_export_plugins_testfile.sav", to.data.frame = TRUE,  :
+  ../import_export_plugins_testfile.sav: position 1: Variable name character 4 is lowercase letter \xDF

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkcommands.R	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkcommands.R	2009-08-11 13:22:41 UTC (rev 2608)
@@ -0,0 +1,24 @@
+local({
+## Prepare
+require (foreign)
+## Compute
+data <- read.spss ("../import_export_plugins_testfile.sav", to.data.frame=TRUE, max.value.labels=1000000)
+
+# set variable labels for use in RKWard
+labels <- attr (data, "variable.labels");
+if (!is.null (labels)) {
+	for (i in 1:length (labels)) {
+		col <- make.names (names (labels[i]))
+		if (!is.null (col)) {
+			rk.set.label (data[[col]], labels[i])
+		}
+	}
+}
+
+my.spss.data <<- data		# assign to globalenv()
+## Print result
+rk.header("Import SPSS data", parameters=list("File", "../import_export_plugins_testfile.sav",
+	"Import as", "my.spss.data"))
+})
+.rk.rerun.plugin.link(plugin="rkward::import_spss", settings="convert_var_labels.state=1\ndata_frame.state=1\ndo_locale_conversion.state=0\ndoedit.state=0\nfile.selection=../import_export_plugins_testfile.sav\nlabels_limit.real=1000000.000000\nsaveto.selection=my.spss.data\ntrim_labels.state=0\nuse_labels.state=1", label="Run again")
+.rk.make.hr()

Added: trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkout	                        (rev 0)
+++ trunk/rkward/tests/import_export_plugins/RKTestStandard.import_spss.rkout	2009-08-11 13:22:41 UTC (rev 2608)
@@ -0,0 +1,33 @@
+<h1>Import SPSS data</h1>
+<h2>Parameters</h2>
+<ul><li>File: ../import_export_plugins_testfile.sav</li>
+<li>Import as: my.spss.data</li>
+</ul>
+DATE<br>
+
+<p align= center >
+<table cellspacing=0 border=1>
+<caption align=bottom class=captiondataframe></caption>
+<tr><td>
+	<table border=0 class=dataframe>
+	<tbody> 
+	<tr class= firstline > 
+		<th>   </th>
+		<th>A_long_variable_name  </th>
+		<th>\xE4\xF6\xFC\xDF\xE9\xC8  </th>
+		<th>Value_labels</th> 
+	</tr> <tr> <td class=firstcolumn>1</td><td class=cellinside> 1</td><td class=cellinside>1.1</td><td class=cellinside> 1</td></tr>
+ <tr> <td class=firstcolumn>2</td><td class=cellinside> </td><td class=cellinside>1.2</td><td class=cellinside> 2</td></tr>
+ <tr> <td class=firstcolumn>3</td><td class=cellinside> 3</td><td class=cellinside>1.3</td><td class=cellinside> 3</td></tr>
+ <tr> <td class=firstcolumn>4</td><td class=cellinside> </td><td class=cellinside>1.4</td><td class=cellinside> 4</td></tr>
+ <tr> <td class=firstcolumn>5</td><td class=cellinside> 5</td><td class=cellinside>1.5</td><td class=cellinside> 5</td></tr>
+ <tr> <td class=firstcolumn>6</td><td class=cellinside> 6</td><td class=cellinside> NA</td><td class=cellinside> 5</td></tr>
+ <tr> <td class=firstcolumn>7</td><td class=cellinside> 7</td><td class=cellinside>1.6</td><td class=cellinside> </td></tr>
+ <tr> <td class=firstcolumn>8</td><td class=cellinside> 7</td><td class=cellinside>1.7</td><td class=cellinside> 5</td></tr>
+ <tr> <td class=firstcolumn>9</td><td class=cellinside> 8</td><td class=cellinside>1.8</td><td class=cellinside> 0</td></tr>
+ 
+	</tbody>
+</table>
+ </td></table>
+ <br>
+<p class='character'>var (Does this variable label show up)</p><p class='character'>var (This contains some regional chars in Windows encoding)</p><p class='character'>var ()</p>
\ No newline at end of file

Modified: trunk/rkward/tests/import_export_plugins.R
===================================================================
--- trunk/rkward/tests/import_export_plugins.R	2009-08-07 16:21:09 UTC (rev 2607)
+++ trunk/rkward/tests/import_export_plugins.R	2009-08-11 13:22:41 UTC (rev 2608)
@@ -51,6 +51,16 @@
 
 			rk.call.plugin ("rkward::setworkdir", dir.selection="import_export_plugins", submit.mode="submit")
 			stopifnot (oldwd == getwd ())
+		}),
+		new ("RKTest", id="import_spss", call=function () {
+			rk.call.plugin ("rkward::import_spss", convert_var_labels.state="1", data_frame.state="1", do_locale_conversion.state="0", doedit.state="0", file.selection="../import_export_plugins_testfile.sav", labels_limit.real="1000000.000000", saveto.selection="my.spss.data", trim_labels.state="0", use_labels.state="1", submit.mode="submit")
+
+			# In order to check, whether the import was correct
+			rk.print (my.spss.data)
+			for (var in my.spss.data) rk.print (rk.get.description(var))
+
+			# WARNING: TODO: We don't use the value labels of the third
+			# variable, yet.
 		})
 	), postCalls = list ()	# like initCalls: run after all tests to clean up. Empty in this case.
 )

Added: trunk/rkward/tests/import_export_plugins_testfile.sav
===================================================================
(Binary files differ)


Property changes on: trunk/rkward/tests/import_export_plugins_testfile.sav
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream


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