diff piechart.r @ 0:74d2bc479bee draft

Uploaded
author davidvanzessen
date Mon, 18 Aug 2014 04:04:37 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/piechart.r	Mon Aug 18 04:04:37 2014 -0400
@@ -0,0 +1,24 @@
+if (!("ggplot2" %in% rownames(installed.packages()))) {
+	install.packages("ggplot2", repos="http://cran.xl-mirror.nl/") 
+}
+library(ggplot2)
+
+args <- commandArgs(trailingOnly = TRUE)
+
+vls = args[1]
+lbls = args[2]
+name = args[3]
+output = args[4]
+
+vls = as.numeric(unlist(strsplit(vls, ",")))
+lbls = unlist(strsplit(lbls, ","))
+
+pc = ggplot(data.frame(Type=lbls, vls=vls), aes(x = factor(1), y=vls, fill=Type))
+pc = pc + geom_bar(width = 1, stat = "identity")
+pc = pc + coord_polar(theta="y")
+pc = pc + xlab(" ") + ylab(" ") + ggtitle(name)
+
+png(filename=output)
+#pie(vls, labels=lbls, col=rainbow(length(vls)), main=name)
+pc
+dev.off()