[rkward-cvs] SF.net SVN: rkward:[2703] trunk/rkward/rkward/plugins/00saveload/import

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Oct 9 13:21:35 UTC 2009


Revision: 2703
          http://rkward.svn.sourceforge.net/rkward/?rev=2703&view=rev
Author:   tfry
Date:     2009-10-09 13:21:35 +0000 (Fri, 09 Oct 2009)

Log Message:
-----------
Suggested changes to Stata import plugin (mail will follow)

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/00saveload/import/import_stata.php
    trunk/rkward/rkward/plugins/00saveload/import/import_stata.rkh
    trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml

Modified: trunk/rkward/rkward/plugins/00saveload/import/import_stata.php
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_stata.php	2009-10-08 10:02:56 UTC (rev 2702)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_stata.php	2009-10-09 13:21:35 UTC (rev 2703)
@@ -1,46 +1,40 @@
 <?php
 function preprocess () { ?>
 require (foreign)
-<?	}
+<?
+}
 
 function calculate () {
+	$options = "";
 
 	if (getRK_val ("convert_dates")) {
-	       $convert_dates_opt = ", convert.dates=TRUE" ;
+	       $options .= ", convert.dates=TRUE" ;
 	} else {
-	       $convert_dates_opt = ", convert.dates=FALSE" ;
+	       $options .= ", convert.dates=FALSE" ;
 	}
 
 	if (getRK_val ("convert_factors")) {
-	       $convert_factors_opt = ", convert.factors=TRUE" ;
+	       $options .= ", convert.factors=TRUE" ;
 	} else {
-	       $convert_factors_opt = ", convert.factors=FALSE" ;
+	       $options .= ", convert.factors=FALSE" ;
 	}
 
 	if (getRK_val ("missing_type")) {
-	       $missing_type_opt = ", missing.type=TRUE" ;
+	       $options .= ", missing.type=TRUE" ;
 	} else {
-	       $missing_type_opt = ", missing.type=FALSE" ;
+	       $options .= ", missing.type=FALSE" ;
 	}
 
 	if (getRK_val ("convert_underscore")) {
-	       $convert_underscore_opt = ", convert.underscore=TRUE" ;
+	       $options .= ", convert.underscore=TRUE" ;
 	} else {
-	       $convert_underscore_opt = ", convert.underscore=FALSE" ;
+	       $options .= ", convert.underscore=FALSE" ;
 	}
 
-	if (getRK_val ("warn_missing_labels")) {
-	       $warn_missing_labels_opt = ", warn.missing.labels=TRUE" ;
-	} else {
-	       $warn_missing_labels_opt = ", warn.missing.lables=FALSE" ;
-	}
-
-
 	$object = getRK_val ("saveto");
 ?>
-data <- read.dta ("<? getRK ("file"); ?>"<? echo ($convert_dates_opt); echo ($convert_factors_opt); echo ($missing_type_opt); echo ($convert_underscore_opt); echo ($warn_missing_labels);  ?>)
+data <- read.dta ("<? getRK ("file"); ?>"<? echo ($options); ?>)
 
-
 # set variable labels for use in RKWard
 labels <- attr (data, "var.labels")
 if (!is.null (labels)) {
@@ -52,8 +46,6 @@
         }
 }
 
-
-
 <? echo ($object); ?> <<- data		# assign to globalenv()
 <?
 	if (getRK_val ("doedit") ) { ?>
@@ -62,5 +54,6 @@
 }
 
 function printout () {
+	makeHeaderCode ("Import Stata File", array ("File" => getRK_val ("file"), "Imported to" => getRK_val ("saveto")));
 }
 ?>

Modified: trunk/rkward/rkward/plugins/00saveload/import/import_stata.rkh
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_stata.rkh	2009-10-08 10:02:56 UTC (rev 2702)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_stata.rkh	2009-10-09 13:21:35 UTC (rev 2703)
@@ -5,20 +5,19 @@
 	</summary>
 
 	<usage>
-Choose the STATA data file to import. Usually those files have the ending '*.dta. An R object containing the STATA data will be created. This can either be a data.frame, or a list. Several options deal with handling labels and character encoding. See <link href="rkward://rhelp/read.dta" />. STATA files other than data files (i. e.:*.log, *.smcl, *.do, *.ado) are not supported. 
+Choose the STATA data file to import. Usually those files have the ending '*.dta. An R object containing the STATA data will be created. STATA files other than data files (i. e.:*.log, *.smcl, *.do, *.ado) are not supported. 
 	</usage>
 
 	<settings>
 		<caption id="tab_general"/>
-		<setting id="file">The filename of the file to import</setting>
+		<setting id="file">The filename of the file to import. This may also be a URL (http://, http:// and ftp:// are supported).</setting>
 		<setting id="saveto">The name of an R object to store the imported data in. If you chose an existing symbol name, you will be prompted, whether to overwrite this object.</setting>
-		<setting id="doedit">Whether the object should be opened for editing after it was imported. Currently, this is only possible, if the object is saved as a data.frame (see next option).</setting>
+		<setting id="doedit">Whether the object should be opened for editing after it was imported. </setting>
 
-		<setting id="convert_dates">Convert Stata dates to R 'Date' class (see <link href="rkward://rhelp/read.dta" />)</setting>
-		<setting id="convert_factors">Use STATA value labels to create factors </setting>
-		<setting id="missing_type"> For version 8 or later, store information about different types of missing data</setting>
-		<setting id="convert_underscore">Convert '_' in Stata variable names to '.' in R names </setting>
-		<setting id="warn_missing_labels">Warn if a variable is specified with value labels and those value labels are not present in the file</setting>
+		<setting id="convert_dates">Convert Stata dates to R 'Date' class (see <link href="rkward://rhelp/read.dta"/>, <link href="rkward://rhelp/Dates"/>).</setting>
+		<setting id="convert_factors">R uses value labels only for factors. Should Stata variable with value labels be converted to factors?</setting>
+		<setting id="missing_type">Stata version 8 and above differentiates various different type of missing values. If this option is set, this information is stored in an attribute of the imported data. See <link href="rkward://rhelp/read.dta"/> for details.</setting>
+		<setting id="convert_underscore">The underscore ('_') is usually not used in R variable names, and may cause problems in some (rare) situations. Should underscore characters be converted to dots ('.')?</setting>
 	</settings>
 	<related>
 		<ul>

Modified: trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml	2009-10-08 10:02:56 UTC (rev 2702)
+++ trunk/rkward/rkward/plugins/00saveload/import/import_stata.xml	2009-10-09 13:21:35 UTC (rev 2703)
@@ -21,7 +21,6 @@
 					<checkbox id="convert_factors" checked="true" label="Use Stata value labels to create factors?" value="1" value_unchecked="0"/>
 					<checkbox id="missing_type" checked="false" label="For version 8 or later, store information about different types of missing data?" value="1" value_unchecked="0"/>
 					<checkbox id="convert_underscore" checked="false" label="Convert '_' in Stata variable names to '.' in R names" value="1" value_unchecked="0"/>
-					<checkbox id="warn_missing_labels" checked="true" label="Warn if a variable is specified with value labels and those value labels are not present in the file." value="1" value_unchecked="0"/>
 				</frame>
 			</tab>
 		</tabbook>


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