[rkward-cvs] SF.net SVN: rkward:[4296] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Aug 30 17:48:35 UTC 2012


Revision: 4296
          http://rkward.svn.sourceforge.net/rkward/?rev=4296&view=rev
Author:   tfry
Date:     2012-08-30 17:48:34 +0000 (Thu, 30 Aug 2012)
Log Message:
-----------
Adjust tests for new options in the 'save_r'-plugin. While add it, also adding a help page, and cleaning file structure.

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/plugins/import_export.pluginmap
    trunk/rkward/tests/import_export_plugins/save_r_object.rkcommands.R
    trunk/rkward/tests/import_export_plugins.R

Added Paths:
-----------
    trunk/rkward/rkward/plugins/00saveload/save/save.js
    trunk/rkward/rkward/plugins/00saveload/save/save.rkh
    trunk/rkward/rkward/plugins/00saveload/save/save.xml

Removed Paths:
-------------
    trunk/rkward/rkward/plugins/00saveload/save/save/code.js
    trunk/rkward/rkward/plugins/00saveload/save/save/description.xml

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2012-08-30 12:44:33 UTC (rev 4295)
+++ trunk/rkward/ChangeLog	2012-08-30 17:48:34 UTC (rev 4296)
@@ -10,7 +10,7 @@
 - Fixed: If the rkward package was loaded in a plain R session, q() and quit() still work
 - combined all Wilcoxon/Mann-Whitney-tests in one plugin (from previously two separate plugins)			TODO: adjust test(s)
 - Added polyserial/polychoric correlations to correlation matrix plugin			TODO: adjust test(s)
-- Added more compression options to the "Save objects as R code" plugin			TODO: adjust test(s)
+- Added more compression options to the "Save objects as R code" plugin
 - Added MacPorts support, see README.MacPorts and bundle build script in the macports folder
 - Added dynamically generated table-of-contents menu to output document
 - Fixed: Would not show output of system() commands to stderr on the console (on Unix-like systems)

Deleted: trunk/rkward/rkward/plugins/00saveload/save/save/code.js
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save/code.js	2012-08-30 12:44:33 UTC (rev 4295)
+++ trunk/rkward/rkward/plugins/00saveload/save/save/code.js	2012-08-30 17:48:34 UTC (rev 4296)
@@ -1,36 +0,0 @@
-// globals
-var data;
-var file;
-
-function calculate(){
-	file = getValue("file");
-	// read in variables from dialog
-	var ascii = getValue("ascii");
-	var compress = getValue("compress");
-	var complevel = getValue("complevel");
-	var xzextreme = getValue("xzextreme");
-
-	// the R code to be evaluated
-	data = getValue("data").split("\n").join(", ");
-	echo("save(" + data);
-	if(file) {
-		echo(",\n\tfile=\"" + file + "\"");
-	}
-	if(ascii) {
-		echo(",\n\tascii=TRUE");
-	}
-	if(compress) {
-		if(compress != "xz" | xzextreme != "true") {
-			echo(",\n\tcompress=\"" + compress + "\",\n\tcompression_level=" + complevel);
-		} else if(xzextreme) {
-			echo(",\n\tcompress=\"" + compress + "\",\n\tcompression_level=-" + complevel);
-		}
-	}
-	echo(")\n\n");
-}
-
-function printout(){
-	// printout the results
-	makeHeaderCode ("Save R objects", new Array("File", file, "Variables", data));
-}
-

Deleted: trunk/rkward/rkward/plugins/00saveload/save/save/description.xml
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save/description.xml	2012-08-30 12:44:33 UTC (rev 4295)
+++ trunk/rkward/rkward/plugins/00saveload/save/save/description.xml	2012-08-30 17:48:34 UTC (rev 4296)
@@ -1,54 +0,0 @@
-<!DOCTYPE rkplugin>
-<document>
-	<code file="code.js"/>
-
-	<logic>
-		<convert id="lgc_compress" sources="compress.string" mode="notequals" />
-		<convert id="lgc_cmprssxz" sources="compress.string" mode="equals" standard="xz" />
-		<connect governor="lgc_compress" client="complevel.enabled" />
-		<connect governor="lgc_cmprssxz" client="xzextreme.enabled" />
-		<script>
-			<![CDATA[ gui.addChangeCommand("compress.string", "compressionChanged()");
-					// try to set compression level dynamically
-					// run each time the compression method is changed
-					compressionChanged = function(){
-							var thisObject = gui.getValue("compress.string");
-							 if(thisObject == "bzip2" | thisObject == "xz"){
-								gui.setValue("complevel.int", 9);
-							} else {
-								gui.setValue("complevel.int", 6);
-							}
-						} ]]>
-		</script>
-	</logic>
-	<dialog label="Save R objects">
-		<tabbook>
-			<tab label="Select variables">
-				<column>
-					<row>
-						<varselector id="vars" />
-						<varslot id="data" label="Object" source="vars" required="true" multi="true" />
-					</row>
-				</column>
-				<row>
-					<frame label="Save to" id="frm_Saveto">
-						<browser label="File name" type="savefile" id="file" initial="my.RData" />
-						<stretch />
-					</frame>
-					<frame label="Options" id="frm_Options">
-						<checkbox id="ascii" label="Ascii" value="true" />
-						<dropdown id="compress" label="Compression">
-							<option label="None" checked="true" />
-							<option label="gzip" value="gzip" />
-							<option label="bzip2" value="bzip2" />
-							<option label="xz" value="xz" />
-						</dropdown>
-						<spinbox label="Compression level" id="complevel" initial="6" min="1" max="9" type="integer" />
-						<checkbox id="xzextreme" label="Enable xz extreme compression" value="true" />
-						<stretch />
-					</frame>
-				</row>
-			</tab>
-		</tabbook>
-	</dialog>
-</document>

Copied: trunk/rkward/rkward/plugins/00saveload/save/save.js (from rev 4291, trunk/rkward/rkward/plugins/00saveload/save/save/code.js)
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save.js	                        (rev 0)
+++ trunk/rkward/rkward/plugins/00saveload/save/save.js	2012-08-30 17:48:34 UTC (rev 4296)
@@ -0,0 +1,36 @@
+// globals
+var data;
+var file;
+
+function calculate(){
+	file = getValue("file");
+	// read in variables from dialog
+	var ascii = getValue("ascii");
+	var compress = getValue("compress");
+	var complevel = getValue("complevel");
+	var xzextreme = getValue("xzextreme");
+
+	// the R code to be evaluated
+	data = getValue("data").split("\n").join(", ");
+	echo("save(" + data);
+	if(file) {
+		echo(",\n\tfile=\"" + file + "\"");
+	}
+	if(ascii) {
+		echo(",\n\tascii=TRUE");
+	}
+	if(compress) {
+		if(compress != "xz" | xzextreme != "true") {
+			echo(",\n\tcompress=\"" + compress + "\",\n\tcompression_level=" + complevel);
+		} else if(xzextreme) {
+			echo(",\n\tcompress=\"" + compress + "\",\n\tcompression_level=-" + complevel);
+		}
+	}
+	echo(")\n\n");
+}
+
+function printout(){
+	// printout the results
+	makeHeaderCode ("Save R objects", new Array("File", file, "Variables", data));
+}
+

Added: trunk/rkward/rkward/plugins/00saveload/save/save.rkh
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save.rkh	                        (rev 0)
+++ trunk/rkward/rkward/plugins/00saveload/save/save.rkh	2012-08-30 17:48:34 UTC (rev 4296)
@@ -0,0 +1,24 @@
+<!DOCTYPE rkhelp>
+<document>
+	<summary>
+		Save one or more selected R objects to a file. <b>Note:</b> Use <i>Workspace->Save Workspace</i> for saving the
+		complete workspace.
+	</summary>
+	<usage>
+		Select the objects to save, and a filename to save to. Created data files can be loaded using <link href="rkward://component/load_r_object"/>.
+	</usage>
+	<settings>
+		<setting id="data">One or more objects to save.</setting>
+		<setting id="file">Location to save to.</setting>
+		<setting id="ascii">Write an ascii, rather than binary representation of the object(s).</setting>
+		<setting id="compress">The file can be compressed to achieve a smaller file size. This control allows to select the method of compression.</setting>
+		<setting id="complevel">Compression level. Higher values indicate better compression.</setting>
+		<setting id="xzextreme">For <i>xz</i> compression, only: Enable xz "extreme" compresison.</setting>
+	</settings>
+	<related>
+		<ul>
+			<li><link href="rkward://rhelp/save"/></li>
+			<li><link href="rkward://component/load_r_object"/></li>
+		</ul>
+	</related>
+</document>

Copied: trunk/rkward/rkward/plugins/00saveload/save/save.xml (from rev 4291, trunk/rkward/rkward/plugins/00saveload/save/save/description.xml)
===================================================================
--- trunk/rkward/rkward/plugins/00saveload/save/save.xml	                        (rev 0)
+++ trunk/rkward/rkward/plugins/00saveload/save/save.xml	2012-08-30 17:48:34 UTC (rev 4296)
@@ -0,0 +1,55 @@
+<!DOCTYPE rkplugin>
+<document>
+	<code file="save.js"/>
+	<help file="save.rkh"/>
+
+	<logic>
+		<convert id="lgc_compress" sources="compress.string" mode="notequals" standard="" />
+		<convert id="lgc_cmprssxz" sources="compress.string" mode="equals" standard="xz" />
+		<connect governor="lgc_compress" client="complevel.enabled" />
+		<connect governor="lgc_cmprssxz" client="xzextreme.enabled" />
+		<script>
+			<![CDATA[ gui.addChangeCommand("compress.string", "compressionChanged()");
+					// try to set compression level dynamically
+					// run each time the compression method is changed
+					compressionChanged = function(){
+							var thisObject = gui.getValue("compress.string");
+							 if(thisObject == "bzip2" | thisObject == "xz"){
+								gui.setValue("complevel.int", 9);
+							} else {
+								gui.setValue("complevel.int", 6);
+							}
+						} ]]>
+		</script>
+	</logic>
+	<dialog label="Save R objects">
+		<tabbook>
+			<tab label="Select variables">
+				<column>
+					<row>
+						<varselector id="vars" />
+						<varslot id="data" label="Object" source="vars" required="true" multi="true" />
+					</row>
+				</column>
+				<row>
+					<frame label="Save to" id="frm_Saveto">
+						<browser label="File name" type="savefile" id="file" initial="my.RData" />
+						<stretch />
+					</frame>
+					<frame label="Options" id="frm_Options">
+						<checkbox id="ascii" label="Ascii" value="true" />
+						<dropdown id="compress" label="Compression">
+							<option label="None" value="" checked="true" />
+							<option label="gzip" value="gzip" />
+							<option label="bzip2" value="bzip2" />
+							<option label="xz" value="xz" />
+						</dropdown>
+						<spinbox label="Compression level" id="complevel" initial="6" min="1" max="9" type="integer" />
+						<checkbox id="xzextreme" label="Enable xz extreme compression" value="true" />
+						<stretch />
+					</frame>
+				</row>
+			</tab>
+		</tabbook>
+	</dialog>
+</document>

Modified: trunk/rkward/rkward/plugins/import_export.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/import_export.pluginmap	2012-08-30 12:44:33 UTC (rev 4295)
+++ trunk/rkward/rkward/plugins/import_export.pluginmap	2012-08-30 17:48:34 UTC (rev 4296)
@@ -12,7 +12,7 @@
 		<component type="standard" id="load_r_object" file="import/load_data.xml" label="Load R data file" />
 		<component type="standard" id="load_source" file="import/source.xml" label="Source an R file" />
 
-		<component type="standard" id="save_r" file="save/save/description.xml" label="Save objects as R data" />
+		<component type="standard" id="save_r" file="save/save.xml" label="Save objects as R data" />
 		<component type="standard" id="save_skeleton" file="save/skeleton/description.xml" label="Create package skeleton" />
 		<component type="standard" id="save_variables" file="save/write.xml" label="Export vector or matrix data" />
 		<component type="standard" id="save_table" file="save/write_table.xml" label="Export tabular data" />

Modified: trunk/rkward/tests/import_export_plugins/save_r_object.rkcommands.R
===================================================================
--- trunk/rkward/tests/import_export_plugins/save_r_object.rkcommands.R	2012-08-30 12:44:33 UTC (rev 4295)
+++ trunk/rkward/tests/import_export_plugins/save_r_object.rkcommands.R	2012-08-30 17:48:34 UTC (rev 4296)
@@ -1,13 +1,22 @@
 local({
 ## Compute
-save (testx, file="x.RData", ascii=TRUE, compress=TRUE)
+save(testx,
+	file="x.RData",
+	ascii=TRUE,
+	compress="gzip",
+	compression_level=6)
+
 ## Print result
 rk.header("Save R objects", parameters=list("File", "x.RData",
 	"Variables", "testx"))
 })
 local({
 ## Compute
-save (testy, file="y.RData", ascii=TRUE, compress=TRUE)
+save(testy,
+	file="y.RData",
+	compress="xz",
+	compression_level=-9)
+
 ## Print result
 rk.header("Save R objects", parameters=list("File", "y.RData",
 	"Variables", "testy"))

Modified: trunk/rkward/tests/import_export_plugins.R
===================================================================
--- trunk/rkward/tests/import_export_plugins.R	2012-08-30 12:44:33 UTC (rev 4295)
+++ trunk/rkward/tests/import_export_plugins.R	2012-08-30 17:48:34 UTC (rev 4296)
@@ -79,8 +79,8 @@
 			assign ("testy", datasets::volcano, envir=globalenv())
 			rk.sync.global()
 
-			rk.call.plugin ("rkward::save_r", ascii.state="TRUE", compress.state="TRUE", data.available="testx", file.selection="x.RData", submit.mode="submit")
-			rk.call.plugin ("rkward::save_r", ascii.state="TRUE", compress.state="TRUE", data.available="testy", file.selection="y.RData", submit.mode="submit")
+			rk.call.plugin ("rkward::save_r", ascii.state="true", complevel.real="6.00", compress.string="gzip", data.available="testx", file.selection="x.RData", submit.mode="submit")
+			rk.call.plugin ("rkward::save_r", ascii.state="", compress.string="xz", complevel.real="9.00", xzextreme.state="true", data.available="testy", file.selection="y.RData", submit.mode="submit")
 
 			rm (testx, testy, envir=globalenv())
 			load ("x.RData")

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