I have detached the data files, which were too large.

> I have used the import_spss template to write an import_stata module.
> I changed the various options and flags from the read.spss() command
> to the read.dta() options. So far it is working for me, although it
> is possible that the code could be cleaned up. I'd be grateful for
> feedback or suggestions and will make changes that are within my
> limited programming capability. If the code is ok, maybe it can be
> included in the next release.

many thanks for your contribution. This will be very useful to have. Looks
good overall, but a few comments:

1) Could you construct a small sample stata file that we can use for testing?
Ideally this would contain a number of variables of different types, with &
without value labels, special missing values, etc. This is both to help us
testing right now, and to create an automated test for your plugin, later
(http://sourceforge.net/apps/mediawiki/rkward/index.php?title=Automated_Plugin_Testing).


I am attaching two not-so-small files for testing (one has value
labels, one has variable labels).  I will construct a single smaller
file soon when I have access to Stata.

2) I believe Stata also has support for variable labels? If so, then it would
be nice to convert those labels to the RKWard format as is done in the
import_spss plugin. (Be sure to include one or two variable labels in the
sample file).


Labeled values of factors are set automatically by read.dta()


Variable labels are included by read.dta() as an attribute of the
data.frame and can be accessed with:

attr (data, "var.labels")

Here is the section of code that I am writing but it's not working
yet.  I get "Error in .subset2(x, i, exact = exact) :
 attempt to select less than one element"

# set variable labels for use in RKWard
labels <- attr (data, "var.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])
               }
       }
}




3) The <logic>-section still has references to the "use_label" checkbox from
the import_spss plugin. Those should be cleaned up.

I have pulled these out and am attaching the new import_stata.xml file

I have also cleaned up the help file import_stata.rkh  and am
attaching that as well.


I have a couple of requests for help:

(1) attaching variable labels is not working.  I have described my
attempt above.

(2) the allow_urls flag in the xml code does not appear to be working for me.

-Michael
<!DOCTYPE rkplugin>
<document>
	<code file="import_stata.php" />
	<help file="import_stata.rkh" />
	<logic>
		<external id="filename"/>
		<connect governor="filename" client="file.selection"/>
	</logic>
	<dialog label="Import STATA file">
		<tabbook>
			<tab id="tab_general" label="General">
				<browser type="file" allow_urls="true" id="file" label="File name" />
				<stretch/>
				<row>
					<saveobject id="saveto" initial="my.stata.data" label="Object to save to"/>
					<checkbox id="doedit" value="1" value_unchecked="0" label="Edit Object" checked="true" />
				</row>
				<stretch/>
				<frame label="Options">
					<checkbox id="convert_dates" checked="true" label="Convert Stata dates to 'Date' class" value="1" value_unchecked="0"/>
					<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>
	</dialog>
</document>

Attachment: import_stata.rkh
Description: Binary data

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
RKWard-devel mailing list
RKWard-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rkward-devel

Reply via email to