[rkward] rkward/plugins/00saveload/import: Some cleanups
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Jan 14 15:21:37 UTC 2016
Git commit 92f0f8352846480950f18e5234dc2f8f5f8ab6b1 by Thomas Friedrichsmeier.
Committed on 14/01/2016 at 15:21.
Pushed by tfry into branch 'master'.
Some cleanups
M +2 -6 rkward/plugins/00saveload/import/import_spss.js
M +2 -6 rkward/plugins/00saveload/import/import_stata.js
M +4 -7 rkward/plugins/00saveload/import/import_xls.js
M +3 -3 rkward/plugins/00saveload/import/import_xls.xml
M +5 -12 rkward/plugins/00saveload/import/import_xls_xlconnect.js
http://commits.kde.org/rkward/92f0f8352846480950f18e5234dc2f8f5f8ab6b1
diff --git a/rkward/plugins/00saveload/import/import_spss.js b/rkward/plugins/00saveload/import/import_spss.js
index e1ae870..c96bb2d 100644
--- a/rkward/plugins/00saveload/import/import_spss.js
+++ b/rkward/plugins/00saveload/import/import_spss.js
@@ -7,14 +7,10 @@ function preprocess () {
function preview () {
preprocess ();
- doCalculate (true);
+ calculate (true);
}
-function calculate () {
- doCalculate (false);
-}
-
-function doCalculate (is_preview) {
+function calculate (is_preview) {
var data_frame = "";
var data_frame_opt = "";
if (getValue ("data_frame") || is_preview) {
diff --git a/rkward/plugins/00saveload/import/import_stata.js b/rkward/plugins/00saveload/import/import_stata.js
index bd936e0..8c8bd85 100644
--- a/rkward/plugins/00saveload/import/import_stata.js
+++ b/rkward/plugins/00saveload/import/import_stata.js
@@ -7,14 +7,10 @@ function preprocess () {
function preview () {
preprocess ();
- doCalculate (true);
+ calculate (true);
}
-function calculate () {
- doCalculate (false);
-}
-
-function doCalculate (is_preview) {
+function calculate (is_preview) {
var options = "";
if (getValue ("convert_dates")) {
diff --git a/rkward/plugins/00saveload/import/import_xls.js b/rkward/plugins/00saveload/import/import_xls.js
index a44ebbe..208c623 100644
--- a/rkward/plugins/00saveload/import/import_xls.js
+++ b/rkward/plugins/00saveload/import/import_xls.js
@@ -3,23 +3,20 @@ function preprocess () {
}
function calculate () {
- var options = "";
-
var header = getValue ("header");
var verbose = getValue ("verbose");
-
var sheet = getValue ("sheetname");
-
+
var quote_char = getValue ("quote");
if (quote_char == "other") quote_char = quote (getValue ("custom_quote"));
-
- options = ", header=" + header + ", verbose=" + verbose;
- var object = getValue ("saveto");
+ var options = ", header=" + header + ", quote=" + quote_char + ", verbose=" + verbose;
echo ('data <- read.xls ("' + getValue ("file") + '", sheet="' + sheet + '"' + options + ', ');
echo (' nrows=' + getValue ("nrows") + ', skip=' + getValue ("skip") + ', na.string="'+ getValue ("na") +'"' + getValue("strings_as_factors") +
', check.names = ' + getValue("checkname") + ', strip.white = ' + getValue("stripwhite") + ')\n');
+
+ var object = getValue ("saveto");
echo ('.GlobalEnv$' + object + ' <- data '); comment ('assign to globalenv()');
if (getValue ("doedit") ) {
echo ('rk.edit (.GlobalEnv$' + object + ')\n');
diff --git a/rkward/plugins/00saveload/import/import_xls.xml b/rkward/plugins/00saveload/import/import_xls.xml
index fcbb378..d93cc96 100644
--- a/rkward/plugins/00saveload/import/import_xls.xml
+++ b/rkward/plugins/00saveload/import/import_xls.xml
@@ -30,9 +30,9 @@
</frame>
<input size="small" initial="NA" id="na" label="Character for missing values" />
<radio id="strings_as_factors" label="Convert character columns to factors" >
- <option value=", stringsAsFactors=TRUE" label="Convert to factor" />
- <option value="" label="Default" checked="true" />
- <option value=", stringsAsFactors=FALSE" label="Do not convert" />
+ <option value=", stringsAsFactors=TRUE" label="Convert to factor" />
+ <option value="" label="Default" checked="true" />
+ <option value=", stringsAsFactors=FALSE" label="Do not convert" />
</radio>
<checkbox id="fill" checked="false" value="TRUE" value_unchecked="FALSE" label="Pad rows if unequal length" />
<checkbox value_unchecked="FALSE" checked="false" value="TRUE" id="stripwhite" label="Strip leading and trailing whitespace" />
diff --git a/rkward/plugins/00saveload/import/import_xls_xlconnect.js b/rkward/plugins/00saveload/import/import_xls_xlconnect.js
index 419d167..7b16eea 100644
--- a/rkward/plugins/00saveload/import/import_xls_xlconnect.js
+++ b/rkward/plugins/00saveload/import/import_xls_xlconnect.js
@@ -1,10 +1,6 @@
include ("convert_encoding.js");
-function preprocess () {
- doPreprocess (false);
-}
-
-function doPreprocess (is_preview) {
+function preprocess (is_preview) {
if (is_preview) {
echo ('if (!base::require (XLConnect)) stop (' + i18n ("Preview not available, because package XLConnect is not installed or cannot be loaded.") + ')\n');
} else {
@@ -14,15 +10,12 @@ function doPreprocess (is_preview) {
}
function preview () {
- doPreprocess (true);
- doCalculate (true);
-}
-
-function calculate () {
- doCalculate (false);
+ preprocess (true);
+ calculate (true);
+ // no printout()
}
-function doCalculate (is_preview) {
+function calculate (is_preview) {
var options = '';
var range = getString ("range");
More information about the rkward-tracker
mailing list