[rkward-cvs] SF.net SVN: rkward: [1870] trunk/rkward/rkward/plugins
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon May 7 15:15:36 UTC 2007
Revision: 1870
http://svn.sourceforge.net/rkward/?rev=1870&view=rev
Author: tfry
Date: 2007-05-07 08:15:35 -0700 (Mon, 07 May 2007)
Log Message:
-----------
Exploring the potential of snippets and includes. Converted t and beta distribution plot plugins to use snippets
Modified Paths:
--------------
trunk/rkward/rkward/plugins/Makefile.am
trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.php
trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.rkh
trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.xml
trunk/rkward/rkward/plugins/distributions/plot_dist_common_snippets.xml
trunk/rkward/rkward/plugins/distributions/plot_t_distribution.php
trunk/rkward/rkward/plugins/distributions/plot_t_distribution.rkh
trunk/rkward/rkward/plugins/distributions/plot_t_distribution.xml
Added Paths:
-----------
trunk/rkward/rkward/plugins/distributions/plot_dist_common_dialog_layout.xml
Modified: trunk/rkward/rkward/plugins/Makefile.am
===================================================================
--- trunk/rkward/rkward/plugins/Makefile.am 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/Makefile.am 2007-05-07 15:15:35 UTC (rev 1870)
@@ -149,6 +149,9 @@
distributions/tukey_probabilities.xml \
distributions/tukey_quantiles.php \
distributions/tukey_quantiles.xml \
+ distributions/plot_dist_common.php \
+ distributions/plot_dist_common_snippets.xml \
+ distributions/plot_dist_common_dialog_layout.xml \
distributions/plot_wilcoxon_distribution.php \
distributions/plot_gamma_distribution.php \
distributions/plot_gamma_distribution.xml \
Modified: trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.php 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.php 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,66 +1,30 @@
<?
-function preprocess () {
-}
+include ("plot_dist_common.php");
-function calculate () {
-}
+function getParameters () {
+ global $options;
-function printout () {
- doPrintout (true);
-}
+ $options['a'] = getRK_val ("a");
+ $options['b'] = getRK_val ("b");
+ $options['ncp'] = getRK_val ("ncp");
+ getContRangeParameters ();
-function preview () {
- preprocess ();
- calculate ();
- doPrintout (false);
-}
-
-function doPrintout ($final) {
- $plot_adds = getRK_val ("plotoptions.code.calculate");
-
- $fun = getRK_val ("function");
- $log_option = "";
- if ($fun == "dbeta") {
- $label = "density";
- $lower_tag = "";
- $tail_tag = "";
- if (getRK_val ("log")) $log_option = ", log=TRUE";
+ if ($options['is_density']) {
+ $options['fun'] = "dbeta";
} else {
- $label = "distribution";
- if (getRK_val("lower") == "1") {
- $lower_tag = ", lower.tail = TRUE";
- $tail_tag = ", \"Tail\",\"Lower\"";
- } else {
- $lower_tag = ", lower.tail = FALSE";
- $tail_tag = ", \"Tail\",\"Upper\"";
- }
- if (getRK_val ("log")) $log_option = ", log.p=TRUE";
+ $options['fun'] = "pbeta";
}
- if (getRK_val ("log") == "1") $log_label="logarithmic";
- else $log_label="normal";
- $n = getRK_val ("n");
- $min = getRK_val ("min");
- $max = getRK_val ("max");
- $a = getRK_val ("a");
- $b = getRK_val ("b");
- $ncp = getRK_val ("ncp");
+}
- if ($final) { ?>
-rk.header ("Beta <? echo ($label); ?> function", list ("Number of Observations", "<? echo ($n); ?>", "Lower quantile", "<? echo ($min); ?>","Upper quantile", "<? echo ($max); ?>", "Shape1", "<? echo ($a); ?>", "Shape2", "<? echo ($b); ?>", "Non-cetrality parameter", "<? echo ($ncp); ?>", "Scaling", "<? echo ($log_label); ?>"<? echo ($tail_tag); ?>, "Function", "<? echo ($fun); ?>"));
+function doHeader () {
+ global $options;
-rk.graph.on ()
-<? }
-?>
-try ({
- curve (<? echo ($fun); ?> (x, shape1 = <? echo ($a); ?>, shape2 = <? echo ($b); ?>, ncp = <? echo ($ncp); ?><? echo ($log_option) ?><? echo ($lower_tag); ?>), from=<? echo ($min); ?>, to=<? echo ($max); ?>, n=<? echo ($n); ?><? getRK ("plotoptions.code.printout"); ?>)
-<? if (!empty ($plot_adds)) { ?>
+ echo ('rk.header ("Beta ' . $options['label'] . ' function", list ("Number of Observations", "' . $options['n'] . '", "Lower quantile", "' . $options['min'] . '", "Upper quantile", "' . $options['max'] . '", "Shape1", "' . $options['a'] . '", "Shape2", "' . $options['b'] . '", "Non-centrality parameter", "' . $options['ncp'] . '"' . $options['log_label'] . $options['tail_label'] . ', "Function", "' . $options['fun'] . '"));' . "\n");
+}
-<?
- printIndented ("\t", $plot_adds);
- } ?>
-})
-<? if ($final) { ?>
-rk.graph.off ()
-<? }
+function doFunCall () {
+ global $options;
+
+ echo ($options['fun'] . '(x, shape1=' . $options['a'] . ', shape2=' . $options['b'] . ', ncp=' . $options['ncp'] . $options['log_option'] . $options['tail_option'] . ')');
}
?>
Modified: trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.rkh 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.rkh 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,28 +1,24 @@
<!DOCTYPE rkhelp>
<document>
+ <snippets>
+ <include file="plot_dist_common_snippets.xml"/>
+ </snippets>
+
<summary>
Density and distribution function plots for the Beta distribution.
</summary>
- <usage>
-Choose appropriate values for the various parameters of the distribution and select the type of function. The "Submit" button will export the plot to the "Output" window. To dynamically visualise the plot check the "Preview" box.
- </usage>
+ <insert snippet="general_usage_help"/>
<settings>
- <setting id="function">
- <li> Density Function, or </li>
- <li> Distribution Function </li>
- </setting>
+ <insert snippet="density_help"/>
<setting id="n">Number of observations (points) for constructing the plot (n).</setting>
<setting id="min">Smallest value at which the function is to be plotted.</setting>
<setting id="max">Largest value at which the function is to be plotted. So, the function will be evaluated at 'n' equally spaced points between the lower quantile and the upper quantile (inclusive of end points).</setting>
<setting id="a"> shape1 paramter of the Beta distribution.</setting>
<setting id="b"> shape2 paramter of the Beta distribution.</setting>
<setting id="ncp">Non-centrality paramter of the Beta distribution.</setting>
- <setting id="log">Check this box if log of the function values are to be plotted.</setting>
- <setting id="lower">This option is valid only for plotting the distribution function. Uncheck this box if the upper tail of the distribution function (P[X > x]) is to be plotted.</setting>
- <setting id="preview">Check this box for previewing the function plot. A new graphics window will pop up and it will be dynamically updated based on the choice of parameters. It may take a while for the window to show up. Sometimes, only an empty graphics device may get displayed, in which case, close the device (dev.off() or may be even graphics.off()), uncheck the box, wait for a while and try again. If it still persists, use only the "Submit" button to view the exported plot in the Output window.</setting>
- <setting id="plotoptions">Various plotting parameter settings for the plot. See the help page of "Plot Options" for more details.</setting>
+ <insert snippet="common_options_help"/>
</settings>
<related>
<ul>
Modified: trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.xml 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_beta_distribution.xml 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,48 +1,28 @@
<!DOCTYPE rkplugin>
-<!--This is the simple "Plot beta probabilities" plugin--><document>
+<document>
<code file="plot_beta_distribution.php" />
<help file="plot_beta_distribution.rkh" />
<logic>
- <convert id="dodist" mode="equals" sources="function.string" standard="pbeta" />
- <connect client="lower.enabled" governor="dodist" />
- <set id="plotoptions.allow_log" to="false"/>
- <set id="plotoptions.allow_grid" to="true"/>
+ <insert snippet="common_logic"/>
</logic>
+ <snippets>
+ <snippet id="range_options">
+ <spinbox type="integer" id="n" initial="100" min="1" label="Number of Observations" />
+ <frame label="Range" >
+ <spinbox default_precision="2" type="real" id="min" initial="0.00" min="0" max="1" label="Lower quantile" />
+ <spinbox default_precision="2" type="real" id="max" initial="1.00" min="0" max="1" label="Upper quantile" />
+ </frame>
+ </snippet>
+ <snippet id="dist_options">
+ <frame label="Parameters">
+ <spinbox default_precision="2" type="real" id="a" initial="2" min="0.01" label="Shape1 (a)" />
+ <spinbox default_precision="2" type="real" id="b" initial="2" min="0.01" label="Shape2 (b)" />
+ <spinbox default_precision="2" type="real" id="ncp" initial="0" min="0" label="Non-centrality parameter (ncp)" />
+ </frame>
+ </snippet>
+ <include file="plot_dist_common_snippets.xml"/>
+ </snippets>
<dialog label="Plot Beta probabilities" >
- <tabbook>
- <tab label="Plot Beta probabilities" >
- <row>
- <column>
- <row>
- <spinbox type="integer" id="n" min="2" initial="100" label="Number of Observations" />
- </row>
- <row>
- <frame label="Range" >
- <spinbox default_precision="2" type="real" id="min" initial="0.00" min="0" max="1" label="Lower quantile" />
- <spinbox default_precision="2" type="real" id="max" initial="1.00" min="0" max="1" label="Upper quantile" />
- </frame>
- </row>
- <row>
- <frame label="Parameters">
- <spinbox default_precision="2" type="real" id="a" initial="2" min="0.01" label="Shape1 (a)" />
- <spinbox default_precision="2" type="real" id="b" initial="2" min="0.01" label="Shape2 (b)" />
- <spinbox default_precision="2" type="real" id="ncp" initial="0" min="0" label="Non-centrality parameter (ncp)" />
- </frame>
- </row>
- </column>
- <column>
- <radio id="function" label="Choose type of function plot" >
- <option value="dbeta" label="Plot density function" />
- <option value="pbeta" label="Plot distribution" />
- </radio>
- <checkbox id="log" label="Logarithmic" value="1" value_unchecked="0"/>
- <checkbox id="lower" label="Lower Tail" value="1" value_unchecked="0" checked="true"/>
- <stretch/>
- <preview id="preview" label="Preview"/>
- <embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />
- </column>
- </row>
- </tab>
- </tabbook>
+ <include file="plot_dist_common_dialog_layout.xml"/>
</dialog>
</document>
Added: trunk/rkward/rkward/plugins/distributions/plot_dist_common_dialog_layout.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_dist_common_dialog_layout.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/plot_dist_common_dialog_layout.xml 2007-05-07 15:15:35 UTC (rev 1870)
@@ -0,0 +1,12 @@
+<!DOCTYPE rkplugin>
+<document>
+ <row>
+ <column>
+ <insert snippet="range_options"/>
+ <insert snippet="dist_options"/>
+ </column>
+ <column>
+ <insert snippet="common_options"/>
+ </column>
+ </row>
+</document>
Modified: trunk/rkward/rkward/plugins/distributions/plot_dist_common_snippets.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_dist_common_snippets.xml 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_dist_common_snippets.xml 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,9 +1,16 @@
<!DOCTYPE rkplugin>
<document>
+ <snippet id="common_logic">
+ <convert id="dodist" mode="equals" sources="function.string" standard="p" />
+ <connect client="lower.enabled" governor="dodist" />
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_grid" to="true"/>
+ </snippet>
+
<snippet id="common_options">
<radio id="function" label="Choose type of function plot" >
- <option value="dt" label="Plot density function" />
- <option value="pt" label="Plot distribution" />
+ <option value="d" label="Plot density function" />
+ <option value="p" label="Plot distribution" />
</radio>
<checkbox id="log" label="Logarithmic" value="1" value_unchecked="0"/>
<checkbox id="lower" label="Lower Tail" value="1" value_unchecked="0" checked="true"/>
@@ -11,12 +18,23 @@
<preview id="preview" label="Preview"/>
<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />
</snippet>
- <snippet id="common_logic">
- <convert id="dodist" mode="equals" sources="function.string" standard="pt" />
- <connect client="lower.enabled" governor="dodist" />
- <set id="plotoptions.allow_log" to="false"/>
+
+ <!-- for the .rkh pages -->
+ <snippet id="common_options_help">
+ <setting id="log">Check this box if log of the function values are to be plotted.</setting>
+ <setting id="lower">This option is valid only for plotting the distribution function. Uncheck this box if the upper tail of the distribution function (P[X > x]) is to be plotted.</setting>
+ <setting id="preview">Check this box for previewing the function plot. A new graphics window will pop up and it will be dynamically updated based on the choice of parameters. It may take a while for the window to show up. Sometimes, only an empty graphics device may get displayed, in which case, close the device (dev.off() or may be even graphics.off()), uncheck the box, wait for a while and try again. If it still persists, use only the "Submit" button to view the exported plot in the Output window.</setting>
+ <setting id="plotoptions">Various plotting parameter settings for the plot. See the help page of "Plot Options" for more details.</setting>
</snippet>
- <snippet id="common_obs">
- <spinbox type="integer" id="n" initial="100" min="1" label="Number of Observations" />
+ <snippet id="general_usage_help">
+ <usage>
+ Choose appropriate values for the various parameters of the distribution and select the type of function. The "Submit" button will export the plot to the "Output" window. To dynamically visualise the plot check the "Preview" box.
+ </usage>
</snippet>
+ <snippet id="density_help">
+ <setting id="function">
+ <li> Density Function, or </li>
+ <li> Distribution Function </li>
+ </setting>
+ </snippet>
</document>
\ No newline at end of file
Modified: trunk/rkward/rkward/plugins/distributions/plot_t_distribution.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_t_distribution.php 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_t_distribution.php 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,58 +1,29 @@
<?
-function preprocess () {
-}
+include ("plot_dist_common.php");
-function calculate () {
-}
+function getParameters () {
+ global $options;
-function printout () {
- doPrintout (true);
-}
+ $options['ncp'] = getRK_val ("ncp");
+ $options['df'] = getRK_val ("df");
+ getContRangeParameters ();
-function preview () {
- preprocess ();
- calculate ();
- doPrintout (false);
-}
-
-function doPrintout ($final) {
-
- $fun = getRK_val ("function");
- $log_option = "";
- if ($fun == "dt") {
- $label = "density";
- $lower_tag = "";
- $tail_tag = "";
- if (getRK_val ("log")) $log_option = ", log=TRUE";
+ if ($options['is_density']) {
+ $options['fun'] = "dt";
} else {
- $label = "distribution";
- if (getRK_val("lower") == "1") {
- $lower_tag = ", lower.tail = TRUE";
- $tail_tag = ", \"Tail\",\"Lower\"";
- } else {
- $lower_tag = ", lower.tail = FALSE";
- $tail_tag = ", \"Tail\",\"Upper\"";
- }
- if (getRK_val ("log")) $log_option = ", log.p=TRUE";
+ $options['fun'] = "pt";
}
- if (getRK_val ("log") == "1") $log_label="logarithmic";
- else $log_label="normal";
- $n = getRK_val ("n");
- $min = getRK_val ("min");
- $max = getRK_val ("max");
- $ncp = getRK_val ("ncp");
- $df = getRK_val ("df");
+}
- if ($final) { ?>
-rk.header ("Student t <? echo ($label); ?> function", list ("Number of Observations", "<? echo ($n); ?>", "Minimum", "<? echo ($min); ?>", "Maximum", "<? echo ($max); ?>", "Degrees of freedom", "<? echo ($df); ?>", "Non-centrality", "<? echo ($ncp); ?>", "Scaling", "<? echo ($log_label); ?>"<? echo ($tail_tag); ?>, "Function", "<? echo ($fun); ?>"));
+function doHeader () {
+ global $options;
-rk.graph.on ()
-<? }
-?>
-try (curve (<? echo ($fun); ?> (x, df = <? echo ($df); ?>, ncp = <? echo ($ncp); ?><? echo ($log_option) ?><? echo ($lower_tag); ?>), from=<? echo ($min); ?>, to=<? echo ($max); ?>, n=<? echo ($n); ?><? getRK ("plotoptions.code.printout"); ?>))
+ echo ('rk.header ("Student t ' . $options['label'] . ' function", list ("Number of Observations", "' . $options['n'] . '", "Minimum", "' . $options['min'] . '", "Maximum", "' . $options['max'] . '", "Degrees of freedom", "' . $options['df'] . '", "Non-centrality", "' . $options['ncp'] . '"' . $options['log_label'] . $options['tail_label'] . ', "Function", "' . $options['fun'] . '"));' . "\n");
+}
-<? if ($final) { ?>
-rk.graph.off ()
-<? }
+function doFunCall () {
+ global $options;
+
+ echo ($options['fun'] . '(x, df=' . $options['df'] . ', ncp=' . $options['ncp'] . $options['log_option'] . $options['tail_option'] . ')');
}
?>
Modified: trunk/rkward/rkward/plugins/distributions/plot_t_distribution.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_t_distribution.rkh 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_t_distribution.rkh 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,32 +1,27 @@
<!DOCTYPE rkhelp>
<document>
+ <snippets>
+ <include file="plot_dist_common_snippets.xml"/>
+ </snippets>
+
<summary>
Density and distribution function plots for the t distribution.
</summary>
- <usage>
-Choose appropriate values for the various parameters of the distribution and select the type of function. The "Submit" button will export the plot to the "Output" window. To dynamically visualise the plot check the "Preview" box.
- </usage>
+ <insert snippet="general_usage_help"/>
<settings>
- <setting id="function">
- <li> Density Function, or </li>
- <li> Distribution Function </li>
- </setting>
+ <insert snippet="density_help"/>
<setting id="n">Number of observations (points) for constructing the plot (n).</setting>
<setting id="min">Smallest value at which the function is to be plotted.</setting>
<setting id="max">Largest value at which the function is to be plotted. So, the function will be evaluated at 'n' equally spaced points between the lower quantile and the upper quantile (inclusive of end points).</setting>
<setting id="df">See R reference on t distribution.</setting>
<setting id="ncp">See R reference on t distribution.</setting>
- <setting id="log">See the description given on Plot Beta distribution help page.</setting>
- <setting id="lower">See the description given on Plot Beta distribution help page.</setting>
- <setting id="preview">See the description given on Plot Beta distribution help page.</setting>
- <setting id="plotoptions">Various plotting parameter settings for the plot. See the help page of "Plot Options" for more details.</setting>
+ <insert snippet="common_options_help"/>
</settings>
<related>
<ul>
<li><link href="rkward://rhelp/TDist"/></li>
- <li><link href="rkward://component/plot_beta_distribution"/></li>
<li><link href="rkward://component/plot_options"/></li>
<li><link href="rkward://rhelp/curve"/></li>
</ul>
Modified: trunk/rkward/rkward/plugins/distributions/plot_t_distribution.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_t_distribution.xml 2007-05-07 11:32:13 UTC (rev 1869)
+++ trunk/rkward/rkward/plugins/distributions/plot_t_distribution.xml 2007-05-07 15:15:35 UTC (rev 1870)
@@ -1,5 +1,5 @@
<!DOCTYPE rkplugin>
-<!--This is the simple "Plot t probabilities" plugin--><document>
+<document>
<code file="plot_t_distribution.php" />
<help file="plot_t_distribution.rkh" />
<logic>
@@ -7,33 +7,21 @@
</logic>
<snippets>
<include file="plot_dist_common_snippets.xml"/>
+ <snippet id="range_options">
+ <spinbox type="integer" id="n" initial="100" min="1" label="Number of Observations" />
+ <frame label="Range" >
+ <spinbox default_precision="2" type="real" id="min" initial="-12.924" label="Lower quantile" />
+ <spinbox default_precision="2" type="real" id="max" initial="12.924" label="Upper quantile" />
+ </frame>
+ </snippet>
+ <snippet id="dist_options">
+ <frame label="Parameters">
+ <spinbox default_precision="2" type="real" id="df" min="0.01" initial="1" label="Degrees of freedom" />
+ <spinbox default_precision="2" type="real" id="ncp" initial="0" label="Non-centrality parameter" />
+ </frame>
+ </snippet>
</snippets>
<dialog label="Plot Student T probabilities" >
- <tabbook>
- <tab label="Plot Student T probabilities" >
- <row>
- <column>
- <row>
- <insert snippet="common_obs"/>
- </row>
- <row>
- <frame label="Range" >
- <spinbox default_precision="2" type="real" id="min" initial="-12.924" label="Lower quantile" />
- <spinbox default_precision="2" type="real" id="max" initial="12.924" label="Upper quantile" />
- </frame>
- </row>
- <row>
- <frame label="Parameters">
- <spinbox default_precision="2" type="real" id="df" min="0.01" initial="1" label="Degrees of freedom" />
- <spinbox default_precision="2" type="real" id="ncp" initial="0" label="Non-centrality parameter" />
- </frame>
- </row>
- </column>
- <column>
- <insert snippet="common_options"/>
- </column>
- </row>
- </tab>
- </tabbook>
+ <include file="plot_dist_common_dialog_layout.xml"/>
</dialog>
</document>
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