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

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Sep 14 13:02:25 UTC 2011


Revision: 3776
          http://rkward.svn.sourceforge.net/rkward/?rev=3776&view=rev
Author:   tfry
Date:     2011-09-14 13:02:25 +0000 (Wed, 14 Sep 2011)
Log Message:
-----------
Embed new tabulation and limitation features in barplot plugin.

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/data/limit_vector_length.xml
    trunk/rkward/rkward/plugins/data/one_var_tabulation.rkh
    trunk/rkward/rkward/plugins/data/one_var_tabulation.xml
    trunk/rkward/rkward/plugins/plots/barplot.js
    trunk/rkward/rkward/plugins/plots/barplot.rkh
    trunk/rkward/rkward/plugins/plots/barplot.xml
    trunk/rkward/rkward/plugins/plots/pareto.xml

Modified: trunk/rkward/rkward/plugins/data/limit_vector_length.xml
===================================================================
--- trunk/rkward/rkward/plugins/data/limit_vector_length.xml	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/data/limit_vector_length.xml	2011-09-14 13:02:25 UTC (rev 3776)
@@ -7,6 +7,9 @@
 		<external id="outvar" default="x"/>
 		<external id="parameters"/>
 
+		<convert id="is_custom_stat" sources="others_statistic.string" mode="equals" standard="custom"/>
+		<connect client="custom_stat.enabled" governor="is_custom_stat"/>
+
 		<script><![CDATA[
 				gui.addChangeCommand ("sorting.string", "updateDescription ()");
 				gui.addChangeCommand ("cutoff.int", "updateDescription ()");

Modified: trunk/rkward/rkward/plugins/data/one_var_tabulation.rkh
===================================================================
--- trunk/rkward/rkward/plugins/data/one_var_tabulation.rkh	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/data/one_var_tabulation.rkh	2011-09-14 13:02:25 UTC (rev 3776)
@@ -31,7 +31,7 @@
 		<ul>
 			<li><i>varsource</i>: The tabulation plugin does not show its own varselector by default. Connect your own to this one (client="embedded_id.varsource.selected", governor="myvarselector_id.selected").</li>
 			<li><i>outvar</i>: By default, the plugin produces a table in a variable called "x". You can set it to use a different name, here.</li>
-			<li><i>titlevar</i>: If you want the plugin to save a description of the grouping variables in an R variable, set this to an object name to use. Defaults to "", i.e. disabled.</li>
+			<li><i>titlevar</i>: If you want the plugin to save a description of the grouping variables in an R variable, set this to an object name to use. Else set this to "" to disable. Defaults to "title"</li>
 			<li><i>fun_label</i>: This property will be set to a description of the statistic.</li>
 			<li><i>parameters</i>: This property will be set to a string describing the tabulation options, suitable for pasting into the "parameters" argument of rk.header().</li>
 		</ul>

Modified: trunk/rkward/rkward/plugins/data/one_var_tabulation.xml
===================================================================
--- trunk/rkward/rkward/plugins/data/one_var_tabulation.xml	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/data/one_var_tabulation.xml	2011-09-14 13:02:25 UTC (rev 3776)
@@ -4,7 +4,7 @@
 	<help file="one_var_tabulation.rkh" />
 	<logic>
 		<external id="outvar" default="x"/>
-		<external id="titlevar" default=""/>
+		<external id="titlevar" default="title"/>
 		<external id="fun_label" default=""Frequency""/>
 		<external id="parameters"/>
 

Modified: trunk/rkward/rkward/plugins/plots/barplot.js
===================================================================
--- trunk/rkward/rkward/plugins/plots/barplot.js	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/plots/barplot.js	2011-09-14 13:02:25 UTC (rev 3776)
@@ -9,28 +9,32 @@
 function doPrintout (full) {
 	var varname = getValue ("x");
 	var names_mode = getValue ("names_mode");
-	var tabulate = getValue ("tabulate");
 
-	var tabulate_header = "";
-	if (tabulate) {
-		tabulate_header = '"Tabulate"="Yes"';
-	} else {
-		tabulate_header = '"Tabulate"="No"';
-	}
+	var tabulate = getValue ("tabulate.checked");
+	var main_header = '"Variable", rk.get.description (' + varname + ')';
+	if (tabulate) main_header = getValue ('tabulate_options.parameters');
 
+	var limit = getValue ("limit.checked");
+	var limit_header = "";
+	if (limit) limit_header = ", " + getValue ('limit_options.parameters');
+
 	var barplot_header = getValue ("barplot_embed.code.preprocess");
 	var barplot_main = getValue ("barplot_embed.code.printout");
 
 
-	echo ('x <- ' + varname + "\n");
 	if (tabulate) {
-		echo ('x <- table(x, exclude=NULL)\n');
+		echo (getValue ('tabulate_options.code.calculate'));
 	} else {
+		echo ('x <- ' + varname + "\n");
 		echo ('# barplot is a bit picky about attributes, so we need to convert to vector explicitely\n');
 		echo ('if(!is.matrix(x)) x <- as.vector(x)\n');
 		echo ('if(!is.matrix(x) && is.data.frame(x)) x <- data.matrix(x)\n');
 	}
 
+	if (limit) {
+		echo (getValue ('limit_options.code.calculate'));
+	}
+
 	if (names_mode == "rexp") {
 		echo ("names(x) <- " + getValue ("names_exp") + "\n");
 	} else if (names_mode == "custom") {
@@ -38,7 +42,7 @@
 	}
 
 	if (full) {
-		echo ('rk.header ("Barplot", parameters=list ("Variable", rk.get.description (' + varname + '), ' + tabulate_header + barplot_header + '))\n');
+		echo ('rk.header ("Barplot", parameters=list (' + main_header + limit_header + barplot_header + '))\n');
 		echo ('\n');
 		echo ('rk.graph.on ()\n');
 	}

Modified: trunk/rkward/rkward/plugins/plots/barplot.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/barplot.rkh	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/plots/barplot.rkh	2011-09-14 13:02:25 UTC (rev 3776)
@@ -10,9 +10,15 @@
 
 	<settings>
 		<caption id="tab_variables"/>
-		<setting id="x">Select a data matrix, a vector or a factor to be plotted.</setting>
-		<setting id="tabulate">Use tabulate option mainly for factor variables or wherever else applicable</setting>
+		<setting id="tabulate">If your data needs to be tabulated / aggregated before plotting, check this option. Refer to <link href="rkward://component/one_var_tabulation"/> for details on the dependent options.</setting>
+		<setting id="x">If your data is already suitable for plotting, directly, specify it here. Otherwise, leave this empty, and check the "Tabulate" option, above.</setting>
+
+		<caption id="tab_limit_options"/>
+		<setting id="limit">If there are very many categories in your data, it may make sense to limit the amount of categories that will be displayed. Check this, if you want to set a limit. See Refer to <link href="rkward://component/limit_vector_length"/> for details on the dependent options.</setting>
+
+		<caption id="tab_labels"/>
 		<setting id="names_mode">Method for assigning labels to the plot. "default" means, the labels are chosen automatically. If no labels are available, this will generally print the values. The other options allow you to specify the labels as literal string, or as an R statement (e.g. if the names are stored in a different variable in the workspace).</setting>
+
 		<caption id="tab_options"/>
 		<setting id="barplot_embed" title="Barplot Options">Since these settings are reused in further plugins, they are documented on a page of their own: See <link href="rkward://component/barplot_embed"/>.</setting>
 	</settings>
@@ -20,7 +26,7 @@
 		<ul>
 			<li><link href="rkward://component/barplot_embed"/></li>
 			<li><link href="rkward://rhelp/barplot"/></li>
-			<li><link href="rkward://rhelp/table"/></li>
+			<li><link href="rkward://component/one_var_tabulation"/></li>
 		</ul>
 	</related>
 </document>

Modified: trunk/rkward/rkward/plugins/plots/barplot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/barplot.xml	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/plots/barplot.xml	2011-09-14 13:02:25 UTC (rev 3776)
@@ -10,35 +10,61 @@
 			<connect client="names_custom.visible" governor="rexp_names.not"/>
 			<connect client="names_custom.enabled" governor="custom_names"/>
 			<connect client="names_exp.visible" governor="rexp_names"/>
-			<connect client="names_exp.required" governor="rexp_names"/>
+
+			<connect client="x.enabled" governor="tabulate.checked.not"/>
+			<connect client="tabulate_options.varsource.selected" governor="vars.selected" />
+			<script><![CDATA[
+				gui.addChangeCommand ("tabulate.checked", "updateFunLabel ()");
+				gui.addChangeCommand ("tabulate_options.fun_label", "updateFunLabel ()");
+				updateFunLabel = function () {
+					if (gui.getValue ("tabulate.checked")) {
+						gui.setValue ("barplot_embed.plotoptions.default_ylab", gui.getValue ("tabulate_options.fun_label"));
+						gui.setValue ("barplot_embed.plotoptions.default_xlab", "title");
+					} else {
+						gui.setValue ("barplot_embed.plotoptions.default_ylab", "");
+						gui.setValue ("barplot_embed.plotoptions.default_xlab", "");
+					}
+				}
+				updateFunLabel ();
+			]]></script>
 		</logic>
-		<dialog label="Barplot" >		
+		<dialog label="Barplot">
 			<tabbook>
 				<tab label="Variables" id="tab_variables">
 					<row>
 						<varselector id="vars"/>
 						<column>
-						<varslot min_vars="1" id="x" source="vars" required="true" label="Matrix, Vector or Factor"/>
-						<checkbox id="tabulate" label="Tabulate" value="1" value_unchecked="0" checked="false" />
-						<stretch/>
-						<frame label="Labels">
+							<frame id="tabulate" label="Tabulate data before plotting" checkable="true" checked="false">
+								<embed id="tabulate_options" component="rkward::one_var_tabulation" as_button="false" label="Tabulation Options"/>
+							</frame>
+
+							<varslot min_vars="1" id="x" source="vars" required="true" label="Matrix, Vector or Factor"/>
+							<stretch/>
+							<preview id="preview"/>
+						</column>
+					</row>
+				</tab>
+				<tab label="Limit" id="tab_limit_options">
+					<frame id="limit" label="Limit number of groups" checkable="true" checked="false">
+						<embed id="limit_options" component="rkward::limit_vector_length" as_button="false" label="Limit Categories"/>
+					</frame>
+					<stretch/>
+				</tab>
+				<tab label="Bar labels" id="tab_labels">
+					<frame label="Bar labels">
 						<radio id="names_mode" label="Labeling" >
 							<option value="default" label="Default labels" checked="true"/>
 							<option value="custom" label="Custom labels"/>
 							<option value="rexp" label="From R expression"/>
 						</radio>
-						<input id="names_exp" label="Expression to use for labels" initial="names (x)"/>
+						<input id="names_exp" label="Expression to use for labels" initial="names (x)" required="true"/>
 						<input id="names_custom" label="Labels (separated by ';')" initial="First label;Second label"/>
 					</frame>
-						<preview id="preview"/>
-						</column>
-					</row>
 				</tab>
 				<tab label="Options" id="tab_options">
-					
 					<embed id="barplot_embed" component="rkward::barplot_embed"/>
+					<stretch/>
 				</tab>
 			</tabbook>
 		</dialog>
-	
 	</document>

Modified: trunk/rkward/rkward/plugins/plots/pareto.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/pareto.xml	2011-09-14 12:24:39 UTC (rev 3775)
+++ trunk/rkward/rkward/plugins/plots/pareto.xml	2011-09-14 13:02:25 UTC (rev 3776)
@@ -10,7 +10,6 @@
 
 		<connect client="x.enabled" governor="tabulate.checked.not"/>
 		<connect client="tabulate_options.varsource.selected" governor="vars.selected" />
-		<set id="tabulate_options.titlevar" to="title" />
 		<script><![CDATA[
 			gui.addChangeCommand ("tabulate.checked", "updateFunLabel ()");
 			gui.addChangeCommand ("tabulate_options.fun_label", "updateFunLabel ()");

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