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

tfry at users.sf.net tfry at users.sf.net
Tue Sep 30 07:59:38 UTC 2014


Revision: 4858
          http://sourceforge.net/p/rkward/code/4858
Author:   tfry
Date:     2014-09-30 07:59:37 +0000 (Tue, 30 Sep 2014)
Log Message:
-----------
Adjust import stata plugin test to use appropriate encoding conversion

Modified Paths:
--------------
    trunk/rkward/tests/import_export_plugins/import_stata.rkcommands.R
    trunk/rkward/tests/import_export_plugins/import_stata.rkout
    trunk/rkward/tests/import_export_plugins.R

Modified: trunk/rkward/tests/import_export_plugins/import_stata.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/import_stata.rkcommands.R	2014-09-30 07:50:57 UTC (rev 4857)
+++ trunk/rkward/tests/import_export_plugins/import_stata.rkcommands.R	2014-09-30 07:59:37 UTC (rev 4858)
@@ -1,9 +1,25 @@
 local({
 ## Prepare
 require (foreign)
+
+# helper function to convert all strings to the current encoding
+iconv.recursive <- function (x, from) {
+	attribs <- attributes (x);
+	if (is.character (x)) {
+		x <- iconv (x, from=from, to="", sub="")
+	} else if (is.list (x)) {
+		x <- lapply (x, function (sub) iconv.recursive (sub, from))
+	}
+	# convert factor levels and all other attributes
+	attributes (x) <- lapply (attribs, function (sub) iconv.recursive (sub, from))
+	x
+}
 ## Compute
 data <- read.dta ("import_export_plugins_testfile.dta", convert.dates=TRUE, convert.factors=TRUE, missing.type=FALSE, convert.underscore=FALSE)
 
+# convert all strings to the current encoding
+data <- iconv.recursive (data, from="ISO8859-1")
+
 # set variable labels for use in RKWard
 labels <- attr (data, "var.labels")
 if (!is.null (labels)) {

Modified: trunk/rkward/tests/import_export_plugins/import_stata.rkout
===================================================================
--- trunk/rkward/tests/import_export_plugins/import_stata.rkout	2014-09-30 07:50:57 UTC (rev 4857)
+++ trunk/rkward/tests/import_export_plugins/import_stata.rkout	2014-09-30 07:59:37 UTC (rev 4858)
@@ -15,7 +15,7 @@
 	<tr class= firstline > 
 		<th>   </th>
 		<th>testvar  </th>
-		<th>special\xE4\xF6\xFC\xDF\xE8chars  </th>
+		<th>specialäöüßèchars  </th>
 		<th>strings</th> 
 	</tr> 
 <tr> 
@@ -43,7 +43,7 @@
 </td>
 <td class=cellinside> 3
 </td>
-<td class=cellinside>value\xF6\xE4\xFC3
+<td class=cellinside>valueöäü3
 </td>
 <td class=cellinside>text
 </td></tr>
@@ -65,7 +65,7 @@
 </td>
 <td class=cellinside>value1
 </td>
-<td class=cellinside>\xE4\xF6\xFC\xDF
+<td class=cellinside>äöüß
 </td></tr>
  
 <tr> 
@@ -75,7 +75,7 @@
 </td>
 <td class=cellinside>value2
 </td>
-<td class=cellinside>$\x80
+<td class=cellinside>$€
 </td></tr>
  
 <tr> 
@@ -83,7 +83,7 @@
 </td>
 <td class=cellinside> 7
 </td>
-<td class=cellinside>value\xF6\xE4\xFC3
+<td class=cellinside>valueöäü3
 </td>
 <td class=cellinside> 
 </td></tr>
@@ -105,6 +105,6 @@
 
 <p class='character'>var (Variable label 1)</p>
 
-<p class='character'>var (Variable label 2 with some special chars: \xE4\xF6\xFC#+߀)</p>
+<p class='character'>var (Variable label 2 with some special chars: äöü#+߀)</p>
 
 <p class='character'>var</p>

Modified: trunk/rkward/tests/import_export_plugins.R
===================================================================
--- trunk/rkward/tests/import_export_plugins.R	2014-09-30 07:50:57 UTC (rev 4857)
+++ trunk/rkward/tests/import_export_plugins.R	2014-09-30 07:59:37 UTC (rev 4858)
@@ -54,7 +54,7 @@
 			# variable, yet.
 		}, libraries=c("foreign"), files=c("../import_export_plugins_testfile.sav")),
 		new ("RKTest", id="import_stata", call=function () {
-			rk.call.plugin ("rkward::import_stata", convert_dates.state="1", convert_factors.state="1", convert_underscore.state="0", doedit.state="0", file.selection="import_export_plugins_testfile.dta", missing_type.state="0", saveto.objectname="my.stata.data", submit.mode="submit")
+			rk.call.plugin ("rkward::import_stata", convert_dates.state="1", convert_factors.state="1", convert_underscore.state="0", do_locale_conversion.state="1", doedit.state="0", encoding.string="ISO8859-1", file.selection="import_export_plugins_testfile.dta", missing_type.state="0", saveto.objectname="my.stata.data", saveto.parent=".GlobalEnv", submit.mode="submit")
 
 			# In order to check, whether the import was correct
 			rk.print (my.stata.data)





More information about the rkward-tracker mailing list