changeset 19:b212836e738d draft

Uploaded
author moheydarian
date Tue, 11 Apr 2017 18:02:50 -0400
parents e4b2d12f4691
children 743a506f2b36
files ggplotscripthistogram.R
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ggplotscripthistogram.R	Tue Apr 11 17:17:38 2017 -0400
+++ b/ggplotscripthistogram.R	Tue Apr 11 18:02:50 2017 -0400
@@ -69,10 +69,13 @@
 #density 
 if(options$density == "counts"){
     gg_density = ggplot(input,aes(value ,color=variable))
-
-} else {
+    gg_freq = NULL
+} else if(options$density == "ndensity"){
     gg_density = ggplot(input,aes(value, ..ncount..,color=variable))
-
+    gg_freq = NULL
+} else if(options$density == "density"){
+    gg_density = ggplot(input,aes(value,color=variable))
+    gg_freq = aes(y=..count../sum(..count..))
 }
 
 #Choose between automatically scaled x and y axis or user defined
@@ -123,7 +126,7 @@
   }
 
 gg_density +
-geom_freqpoly(binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+
+geom_freqpoly(gg_freq,binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+
 gg_scalex+gg_scaley+theme_bw()+xlab(options$xlab)+ylab(options$ylab)+gg_legend+
 ggtitle(options$title)