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

sjar at users.sourceforge.net sjar at users.sourceforge.net
Sun Dec 11 00:18:10 UTC 2011


Revision: 4094
          http://rkward.svn.sourceforge.net/rkward/?rev=4094&view=rev
Author:   sjar
Date:     2011-12-11 00:18:10 +0000 (Sun, 11 Dec 2011)
Log Message:
-----------
* mean in boxplot got some more variations (geometric mean, harmonic mean, interquantile mean) to chose from

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/plots/box_plot.js
    trunk/rkward/rkward/plugins/plots/box_plot.rkh
    trunk/rkward/rkward/plugins/plots/box_plot.xml

Modified: trunk/rkward/rkward/plugins/plots/box_plot.js
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.js	2011-12-10 23:12:41 UTC (rev 4093)
+++ trunk/rkward/rkward/plugins/plots/box_plot.js	2011-12-11 00:18:10 UTC (rev 4094)
@@ -55,13 +55,37 @@
 		echo ('rk.graph.on()\n');
 	}
 	echo ('try (boxplot (data_list' + boxwex + positions + ', notch = ' + getValue ("notch") + ', outline = ' + getValue("outline") + ', horizontal = ' + getValue("orientation") + getValue ("plotoptions.code.printout") + ')) #actual boxplot function\n');
-	if (mean == "TRUE") {
+	if (mean == "TRUE" & (getValue ("type_of_mean") =="arithmetic_mean")) {
 		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');
+			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');
+			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" & (getValue ("type_of_mean") =="geometric_mean")) {
+	  echo('	geo_mean <- function (x) {prod(na.omit(x))^1/length(na.omit(x))}	#Calculate geometric mean\n');
+	  if (horizontal) {
+	    echo ('	try (points(1:length(data_list) ~ sapply(data_list,geo_mean), 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,geo_mean), 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" & (getValue ("type_of_mean") =="harmonic_mean")) {
+	  echo('	har_mean <- function (x) {(1 / mean(1 / na.omit(x)))}	#Calculate harmonic mean\n');
+	  if (horizontal) {
+	    echo ('	try (points(1:length(data_list) ~ sapply(data_list,har_mean), 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,har_mean), 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" & (getValue ("type_of_mean") =="interquantile_mean")) {
+	  echo('	interq_mean <- function (x) {sum(quantile(x, probs=c(0.25), na.rm=T), quantile(x, probs=c(0.75), na.rm=TRUE)) / 2}	#Calculate interquantile mean\n');
+	  if (horizontal) {
+	    echo ('	try (points(1:length(data_list) ~ sapply(data_list,interq_mean), 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,interq_mean), 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") {
 		echo ('	sd_low <- (sapply(data_list,mean,na.rm = TRUE)) - (sapply(data_list,sd,na.rm = TRUE))\n');

Modified: trunk/rkward/rkward/plugins/plots/box_plot.rkh
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.rkh	2011-12-10 23:12:41 UTC (rev 4093)
+++ trunk/rkward/rkward/plugins/plots/box_plot.rkh	2011-12-11 00:18:10 UTC (rev 4094)
@@ -23,6 +23,7 @@
 		<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="type_of_mean">Use this option to select a specific type of mean. The arithmetic mean is the default. Others include the geometric mean, the harmonic mean and interquantile mean.</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>

Modified: trunk/rkward/rkward/plugins/plots/box_plot.xml
===================================================================
--- trunk/rkward/rkward/plugins/plots/box_plot.xml	2011-12-10 23:12:41 UTC (rev 4093)
+++ trunk/rkward/rkward/plugins/plots/box_plot.xml	2011-12-11 00:18:10 UTC (rev 4094)
@@ -78,6 +78,12 @@
 					<frame label="Mean">
 						<checkbox id="mean" checked="false" value="TRUE" label="show mean" />
 						<spinbox type="integer" id="pch_mean" label="mean symbol" initial="15"/>
+						<radio id="type_of_mean" label="Type of mean" >
+						  <option value="arithmetic_mean" label="Arithmetic mean" checked="true" />
+						  <option value="geometric_mean" label="Geometric mean" />
+						  <option value="harmonic_mean" label="Harmonic mean" />
+						  <option value="interquantile_mean" label="Interquantile mean" />
+						</radio>
 					</frame>
 					<frame label="SD">
 						<checkbox id="sd" checked="false" value="TRUE" label="show standard deviation" />

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