Mercurial > repos > moheydarian > ggplot_histogram
comparison ggplotscripthistogram.R @ 19:b212836e738d draft
Uploaded
| author | moheydarian |
|---|---|
| date | Tue, 11 Apr 2017 18:02:50 -0400 |
| parents | e4b2d12f4691 |
| children | eeff8405f1ac |
comparison
equal
deleted
inserted
replaced
| 18:e4b2d12f4691 | 19:b212836e738d |
|---|---|
| 67 } | 67 } |
| 68 | 68 |
| 69 #density | 69 #density |
| 70 if(options$density == "counts"){ | 70 if(options$density == "counts"){ |
| 71 gg_density = ggplot(input,aes(value ,color=variable)) | 71 gg_density = ggplot(input,aes(value ,color=variable)) |
| 72 | 72 gg_freq = NULL |
| 73 } else { | 73 } else if(options$density == "ndensity"){ |
| 74 gg_density = ggplot(input,aes(value, ..ncount..,color=variable)) | 74 gg_density = ggplot(input,aes(value, ..ncount..,color=variable)) |
| 75 | 75 gg_freq = NULL |
| 76 } else if(options$density == "density"){ | |
| 77 gg_density = ggplot(input,aes(value,color=variable)) | |
| 78 gg_freq = aes(y=..count../sum(..count..)) | |
| 76 } | 79 } |
| 77 | 80 |
| 78 #Choose between automatically scaled x and y axis or user defined | 81 #Choose between automatically scaled x and y axis or user defined |
| 79 if(options$scaling == "Automatic"){ | 82 if(options$scaling == "Automatic"){ |
| 80 gg_scalex = NULL | 83 gg_scalex = NULL |
| 121 } else { | 124 } else { |
| 122 gg_colorscale = scale_color_brewer(palette=options$colors, direction=options$colororder) | 125 gg_colorscale = scale_color_brewer(palette=options$colors, direction=options$colororder) |
| 123 } | 126 } |
| 124 | 127 |
| 125 gg_density + | 128 gg_density + |
| 126 geom_freqpoly(binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+ | 129 geom_freqpoly(gg_freq,binwidth=options$binwidth,size=options$size)+gg_facet+gg_colorscale+ |
| 127 gg_scalex+gg_scaley+theme_bw()+xlab(options$xlab)+ylab(options$ylab)+gg_legend+ | 130 gg_scalex+gg_scaley+theme_bw()+xlab(options$xlab)+ylab(options$ylab)+gg_legend+ |
| 128 ggtitle(options$title) | 131 ggtitle(options$title) |
| 129 | 132 |
| 130 ggsave(file=options$output) | 133 ggsave(file=options$output) |
