> 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")
I am attaching a new version of import_stata.php that correctly handles variable labels (the structure of the attribute differed slightly between SPSS and Stata: first, the attribute is var.labels rather than variable.labels; second, the var.labels attribute did not have variable names as column names; so the match has to be done by column number). Here is the relevant stretch of code for importing Stata variable labels. # 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 (attr (data, "names")[i] ) if (!is.null (col)) { rk.set.label (data[[col]], labels[i]) } } } Try this on http://wps.aw.com/wps/media/objects/3254/3332253/datasets2e/datasets/Smoking.dta and you should see the labels for the variables. Best, Michael
<<attachment: import_stata.php>>
------------------------------------------------------------------------------ Come build with us! The BlackBerry® 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-12, 2009. Register now! http://p.sf.net/sfu/devconf
_______________________________________________ RKWard-devel mailing list RKWard-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rkward-devel