[rkward-cvs] SF.net SVN: rkward:[3531] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Wed Apr 27 11:56:34 UTC 2011
Revision: 3531
http://rkward.svn.sourceforge.net/rkward/?rev=3531&view=rev
Author: tfry
Date: 2011-04-27 11:56:34 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
Support grouped data in boxplot. Also simplify the js code a bit, and make use of rk.list(). Add help page.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/plugins/plots/box_plot.js
trunk/rkward/rkward/plugins/plots/box_plot.xml
Added Paths:
-----------
trunk/rkward/rkward/plugins/plots/box_plot.rkh
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2011-04-27 11:54:37 UTC (rev 3530)
+++ trunk/rkward/ChangeLog 2011-04-27 11:56:34 UTC (rev 3531)
@@ -1,3 +1,4 @@
+- Box plot plugin gains supported for grouped outcome data
- Fixed: Pressing Ctrl+C would not reset syntactically incomplete commands in the R console
- Crosstabs N to 1 plugin gains options to compute proportions and margins (thanks to Andrés Necochea) TODO: update / add automated test(s)
- Added convenience R function rk.list() to allow simplification of plugin code # TODO: ideally, this should be used in all applicable plugins
@@ -16,7 +17,7 @@
- Fixed: Object name completion would abort early in the script editor with KDE 4.4
- Support function argument hinting for R primitives
- Support package namespaces in object name completion and workspace browser
-- Support S4 slots in object name completion and workspace browser TODO: more testing
+- Support S4 slots in object name completion and workspace browser
- More correct handling of quotes in object name completion
- Support plot history for ggplot2 plots
- Be less pro-active about fetching structure information on R objects in the workspace TODO: verify that this fixes our issues with rXML
Modified: trunk/rkward/rkward/plugins/plots/box_plot.js
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.js 2011-04-27 11:54:37 UTC (rev 3530)
+++ trunk/rkward/rkward/plugins/plots/box_plot.js 2011-04-27 11:56:34 UTC (rev 3531)
@@ -7,27 +7,22 @@
}
function doPrintout (full) {
- var xvarsstring = "";
- var names_mode = "";
- var mean = "";
- var pch_mean = "";
- var sd = "";
- var pch_sd_high = "";
- var pch_sd_low = "";
- var horizontal = "";
- var plot_adds = "";
- xvarsstring = getValue ("x").split ("\n").join (", ");
- names_mode = getValue ("names_mode");
- mean = getValue ("mean");
- pch_mean = getValue ("pch_mean");
- sd = getValue ("sd");
- pch_sd_high = getValue ("pch_sd_high");
- pch_sd_low = getValue ("pch_sd_low");
- horizontal = getValue ("orientation");
- plot_adds = getValue ("plotoptions.code.calculate"); //add grid and alike
+ var grouped_mode = getValue ("data_mode_grouped.numeric");
+ var names_mode = getValue ("names_mode");
+ var mean = getValue ("mean");
+ var pch_mean = getValue ("pch_mean");
+ var sd = getValue ("sd");
+ var pch_sd_high = getValue ("pch_sd_high");
+ var pch_sd_low = getValue ("pch_sd_low");
+ var horizontal = getValue ("orientation") == "TRUE";
+ var plot_adds = getValue ("plotoptions.code.calculate"); //add grid and alike
-
- echo ('data_list <- list (' + xvarsstring + ') #convert single sample variables to list\n');
+ if (grouped_mode) {
+ echo ('groups <- rk.list (' + getValue ("groups").split ("\n").join (", ") + ')\n');
+ echo ('data_list <- split (' + getValue ("outcome") + ', groups) #split sample by grouping variables\n');
+ } else {
+ echo ('data_list <- rk.list (' + getValue ("x").split ("\n").join (", ") + ') #convert single sample variables to list\n');
+ }
if (names_mode == "rexp") {
echo ("names(data_list) <- " + getValue ("names_exp") + "\n");
} else if (names_mode == "custom") {
@@ -35,29 +30,33 @@
}
if (full) {
- echo ('rk.header ("Boxplot", list ("Variable(s)", rk.get.description (' + xvarsstring + ', paste.sep=", ")))\n');
+ if (grouped_mode) {
+ echo ('rk.header ("Boxplot", list ("Outcome variable", rk.get.description (' + getValue ("outcome") + '), "Grouping variable(s)", paste (names (groups), collapse=", ")))\n');
+ } else {
+ echo ('rk.header ("Boxplot", list ("Variable(s)", paste (names (data_list), collapse=", ")))\n');
+ }
echo ('rk.graph.on()\n');
}
echo ('try (boxplot (data_list, notch = ' + getValue ("notch") + ', outline = ' + getValue("outline") + ', horizontal = ' + getValue("orientation") + getValue ("plotoptions.code.printout") + ')) #actuall boxplot function\n');
- if ((mean == "TRUE") && (horizontal == "TRUE")) {
- echo (' try (points(1:length(data_list) ~ sapply(data_list,mean,na.rm = TRUE),pch=' + pch_mean + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')) #calculates the mean for all data and adds a point at the corresponding position\n');
+ if (mean == "TRUE") {
+ if (horizontal) {
+ echo (' try (points(1:length(data_list) ~ sapply(data_list,mean,na.rm = TRUE),pch=' + pch_mean + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')) #calculates the mean for all data and adds a point at the corresponding position\n');
+ } else {
+ echo (' try (points(sapply(data_list,mean,na.rm = TRUE),pch=' + pch_mean + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')) #calculates the mean for all data and adds a point at the corresponding position\n');
+ }
}
- if ((mean == "TRUE") && (horizontal == "FALSE")) {
- echo (' try (points(sapply(data_list,mean,na.rm = TRUE),pch=' + pch_mean + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')) #calculates the mean for all data and adds a point at the corresponding position\n');
- }
- if ((sd == "TRUE") && (horizontal == "FALSE")) {
+ if (sd == "TRUE") {
echo (' sd_low <- (sapply(data_list,mean,na.rm = TRUE)) - (sapply(data_list,sd,na.rm = TRUE))\n');
echo (' sd_high <- (sapply(data_list,mean,na.rm = TRUE)) + (sapply(data_list,sd,na.rm = TRUE))\n');
- echo (' points(sd_low,pch=' + pch_sd_low + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
- echo (' points(sd_high,pch=' + pch_sd_high + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
+ if (horizontal) {
+ echo (' points(1:length(data_list) ~ sd_low,pch=' + pch_sd_low + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
+ echo (' points(1:length(data_list) ~ sd_high,pch=' + pch_sd_high + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
+ } else {
+ echo (' points(sd_low,pch=' + pch_sd_low + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
+ echo (' points(sd_high,pch=' + pch_sd_high + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
+ }
}
- if ((sd == "TRUE") && (horizontal == "TRUE")) {
- echo (' sd_low <- (sapply(data_list,mean,na.rm = TRUE)) - (sapply(data_list,sd,na.rm = TRUE))\n');
- echo (' sd_high <- (sapply(data_list,mean,na.rm = TRUE)) + (sapply(data_list,sd,na.rm = TRUE))\n');
- echo (' points(1:length(data_list) ~ sd_low,pch=' + pch_sd_low + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
- echo (' points(1:length(data_list) ~ sd_high,pch=' + pch_sd_high + ', cex = ' + getValue ("cex_sd_mean") + getValue ("sd_mean_color.code.printout") + ')\n');
- }
if (plot_adds.length > 0) {
echo ('\n');
Added: trunk/rkward/rkward/plugins/plots/box_plot.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/plots/box_plot.rkh 2011-04-27 11:56:34 UTC (rev 3531)
@@ -0,0 +1,37 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+Creates a box plot of one or more variables.
+ </summary>
+
+ <usage>
+Chose numerical data to be plotted. Data can be organized in separate vectors, or in a single outcome variable and one or more grouping variables.
+ </usage>
+
+ <settings>
+ <caption id="tab_variables"/>
+ <setting id="data_mode">Select the format of your data. This can either be separate numerical vectors, or a single outcome variable split by one or more grouping variables.</setting>
+ <setting id="x">For separate variables mode: Select one or more numerical vectors.</setting>
+ <setting id="outcome">For single(grouped) variable mode: Select one numerical vectors as the outcome variable.</setting>
+ <setting id="groups">For single(grouped) variable mode: Select one or more vectors by which to group the outcome variable. Group variables should have the same length as the outcome variable.</setting>
+ <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="orientation">Orientation of the plot: horizontal or vertical.</setting>
+ <setting id="notch">Whether to draw notches</setting>
+ <setting id="outline">Whether to draw outliers (if any). Outliers are draw as dots, if this option is checked.</setting>
+ <setting id="mean">Whether to draw a mark indicating the mean.</setting>
+ <setting id="pch_mean">If the mean is to be indicated: Symbol to use as mark.</setting>
+ <setting id="sd">Whether to draw a mark indicating the standard deviation.</setting>
+ <setting id="pch_sd_high">If the standard deviation is to be indicated: Symbol to use as mark for the upper sd.</setting>
+ <setting id="pch_sd_low">If the standard deviation is to be indicated: Symbol to use as mark for the lower sd.</setting>
+ <setting id="cex_sd_mean">Size of mean / sd idicators. This option is only availble, if at least one of mean or sd are to be drawn.</setting>
+ <setting id="sd_mean_color">Color of mean / sd idicators. This option is only availble, if at least one of mean or sd are to be drawn.</setting>
+ <setting id="plotoptions" title="General plot Options">Since these settings are reused in further plugins, they are documented on a page of their own: See <link href="rkward://component/plot_options"/>.</setting>
+ </settings>
+ <related>
+ <ul>
+ <li><link href="rkward://component/barplot"/></li>
+ <li><link href="rkward://rhelp/boxplot"/></li>
+ </ul>
+ </related>
+</document>
Modified: trunk/rkward/rkward/plugins/plots/box_plot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.xml 2011-04-27 11:54:37 UTC (rev 3530)
+++ trunk/rkward/rkward/plugins/plots/box_plot.xml 2011-04-27 11:56:34 UTC (rev 3531)
@@ -1,6 +1,7 @@
<!DOCTYPE rkplugin>
<document>
<code file="box_plot.js" />
+ <help file="box_plot.rkh" />
<logic>
<connect client="plotoptions.xvar" governor="x.available"/>
<set id="plotoptions.allow_type" to="true"/>
@@ -8,7 +9,15 @@
<set id="plotoptions.allow_xlim" to="false"/>
<set id="plotoptions.allow_log" to="false"/>
<set id="plotoptions.allow_grid" to="true"/>
-
+
+ <convert id="data_mode_grouped" mode="equals" sources="data_mode.string" standard="grouped_outcome"/>
+ <connect client="outcome.visible" governor="data_mode_grouped"/>
+ <connect client="outcome.required" governor="data_mode_grouped"/>
+ <connect client="groups.visible" governor="data_mode_grouped"/>
+ <connect client="groups.required" governor="data_mode_grouped"/>
+ <connect client="x.visible" governor="data_mode_grouped.not"/>
+ <connect client="x.required" governor="data_mode_grouped.not"/>
+
<convert id="custom_names" mode="equals" sources="names_mode.string" standard="custom"/>
<convert id="rexp_names" mode="equals" sources="names_mode.string" standard="rexp"/>
<connect client="names_custom.visible" governor="rexp_names.not"/>
@@ -24,10 +33,18 @@
</logic>
<dialog label="Boxplot" >
<tabbook>
- <tab label="Variable(s)" >
+ <tab label="Variable(s)" id="tab_variables">
<row>
<varselector id="vars" />
- <varslot multi="true" type="numeric" source="vars" id="x" label="variable(s):" required="true" />
+ <column>
+ <radio id="data_mode" label="Data format">
+ <option value="separate_vars" label="Separate variables" checked="true"/>
+ <option value="grouped_outcome" label="Single (grouped) variable"/>
+ </radio>
+ <varslot multi="true" type="numeric" source="vars" id="x" label="Variable(s):"/>
+ <varslot type="numeric" source="vars" id="outcome" label="Outcome variable:"/>
+ <varslot multi="true" source="vars" id="groups" label="Group variable(s):"/>
+ </column>
<stretch/>
<frame label="Labels">
<radio id="names_mode" label="Labeling" >
@@ -41,7 +58,7 @@
</row>
<preview id="preview"/>
</tab>
- <tab label="Options" >
+ <tab label="Options" id="tab_options">
<row>
<column>
<radio id="orientation" label="orientation" >
@@ -49,7 +66,7 @@
<option checked="true" value="FALSE" label="vertical" />
</radio>
<checkbox id="notch" label="Draw Notches" checked="false" value="TRUE" value_unchecked="FALSE" />
- <checkbox id="outline" label="Outline" checked="true" value="TRUE" value_unchecked="FALSE" />
+ <checkbox id="outline" label="Draw Outliers" checked="true" value="TRUE" value_unchecked="FALSE" />
<stretch/>
<frame id="size_and_color_frame" label="Size and color of marks">
<spinbox type="real" id="cex_sd_mean" label="size" initial="1"/>
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