[chronojump] Updated server r-sqlite scripts



commit 5b1f96a66c5c0a1f92ef340822f07f15b1a3a67b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Jul 5 16:31:53 2013 +0200

    Updated server r-sqlite scripts

 chronojump_server/r-sqlite/evaluators.R            |   27 +++++++++++--------
 chronojump_server/r-sqlite/ieiub.R                 |    7 +++--
 chronojump_server/r-sqlite/persons.R               |   18 ++++++------
 chronojump_server/r-sqlite/tf_by_age.R             |    7 +++--
 chronojump_server/r-sqlite/tf_by_extra_weight.R    |    7 +++--
 chronojump_server/r-sqlite/tf_by_jumps_boxplot.R   |   10 ++++---
 .../r-sqlite/tf_by_level_sex_jumptype.R            |    7 +++--
 7 files changed, 47 insertions(+), 36 deletions(-)
---
diff --git a/chronojump_server/r-sqlite/evaluators.R b/chronojump_server/r-sqlite/evaluators.R
index ff5a5ef..edac044 100644
--- a/chronojump_server/r-sqlite/evaluators.R
+++ b/chronojump_server/r-sqlite/evaluators.R
@@ -1,14 +1,14 @@
-#change from local to server ----------------------------
-#server
-library(GDD)
-GDD(file="/var/www/web/server/images/evaluators.png", type="png", w=670, h=670)
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+#library(GDD)
+#GDD(file="/var/www/web/server/images/evaluators.png", type="png", w=670, h=670) #server PNG
+#file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+png(file="evaluators.png", w=800, h=800) #local PNG
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 title = "Data uploaded by evaluator"
 subtitle=paste(Sys.Date(),"(YYYY-MM-DD)")
 colors=topo.colors(3)
 col.sub="red"
 
-#local
+#local PDF
 #pdf(file="evaluators.pdf", width=7, height=7)
 #file = "/home/xavier/.local/share/Chronojump/database/chronojump_server_2012-03-06.db"
 #title = ""
@@ -104,12 +104,17 @@ par(mar=c(5,4,5.5,2), oma=c(1,7,1,1))
 
 barplot(t(b), horiz=T, las=2, col=colors, cex.names=cex,axes=F)
 axis(3, cex.axis=.8)
-legend("right", colnames(b), pch=15, col=colors, cex=.8)
+
+#plot legend on top exactly out
+#http://stackoverflow.com/a/7322792
+rng=par("usr")
+lg = legend(rng[1],rng[2], ncol=3, colnames(b), pch=15, col=colors, cex=.8)
+legend(rng[2]-lg$rect$w,rng[3]+lg$rect$h, ncol=3, colnames(b), pch=15, col=colors, cex=.8)
 
 title(main=title, sub=subtitle, cex.sub = 0.75, font.sub = 3, col.sub = col.sub)
 
 par(new=TRUE)
-par(mar=c(5.2,12,18.4,2))
+par(mar=c(9,13,18,2))
 
 persons <- dbGetQuery(con, "SELECT session.uploadedDate AS date, count(personSession77.uniqueID) AS conta 
FROM session,personSession77 WHERE personSession77.sessionID == session.UniqueID AND session.uploadedDate != 
'2007-07-30' GROUP BY session.uploadedDate;")
 jumps <- dbGetQuery(con, "SELECT session.uploadedDate AS date, count(jump.uniqueID) AS conta FROM 
session,jump WHERE jump.sessionID == session.UniqueID AND session.uploadedDate != '2007-07-30' GROUP BY 
session.uploadedDate;")
@@ -119,11 +124,11 @@ minx=min(dates)
 maxx=max(dates)
 maxy=max(c(sum(persons$conta),sum(jumps$conta),sum(jumpsRj$conta)))
 
-plot(as.Date(persons$date), cumsum(persons$conta), type='s', lwd=2, col=colors[1], xlim=c(minx,maxx), 
ylim=c(0,maxy), ylab="", cex.axis=.8, las=T)
+plot(as.Date(persons$date), cumsum(persons$conta), type='s', lwd=2, col=colors[1], xlim=c(minx,maxx), 
ylim=c(0,maxy), xlab="", ylab="", cex.axis=.8, las=T)
 abline(v=seq(as.Date("2009/1/1"), as.Date("2020/1/1"), by="3 months"),lty=3)
 par(new=TRUE)
-plot(as.Date(jumps$date), cumsum(jumps$conta), type='s', lwd=2, col=colors[2], xlim=c(minx,maxx), 
ylim=c(0,maxy), ylab="", axes=F)
+plot(as.Date(jumps$date), cumsum(jumps$conta), type='s', lwd=2, col=colors[2], xlim=c(minx,maxx), 
ylim=c(0,maxy), xlab="", ylab="", axes=F)
 par(new=TRUE)
-plot(as.Date(jumpsRj$date), cumsum(jumpsRj$conta), type='s', lwd=2, col=colors[3], xlim=c(minx,maxx), 
ylim=c(0,maxy), ylab="", axes=F)
+plot(as.Date(jumpsRj$date), cumsum(jumpsRj$conta), type='s', lwd=2, col=colors[3], xlim=c(minx,maxx), 
ylim=c(0,maxy), xlab="", ylab="", axes=F)
 
 dev.off()
diff --git a/chronojump_server/r-sqlite/ieiub.R b/chronojump_server/r-sqlite/ieiub.R
index 7a4987a..d80850b 100644
--- a/chronojump_server/r-sqlite/ieiub.R
+++ b/chronojump_server/r-sqlite/ieiub.R
@@ -1,9 +1,10 @@
-library(GDD)
-GDD(file="/var/www/web/server/images/ieiub.png", type="png", w=670, h=670)
+#library(GDD)
+#GDD(file="/var/www/web/server/images/ieiub.png", type="png", w=670, h=670)
+png(file="ieiub.png", w=800, h=800) #local PNG
 
 library(RSQLite)
 drv = dbDriver("SQLite")
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 con = dbConnect(drv, file)
 
 def.par <- par(no.readonly = TRUE) # save default, for resetting...
diff --git a/chronojump_server/r-sqlite/persons.R b/chronojump_server/r-sqlite/persons.R
index 18b385e..2b1b45d 100644
--- a/chronojump_server/r-sqlite/persons.R
+++ b/chronojump_server/r-sqlite/persons.R
@@ -1,15 +1,15 @@
-#change from local to server ----------------------------
-#server
-library(GDD)
-GDD(file="/var/www/web/server/images/persons.png", type="png", w=670, h=670)
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+#library(GDD)
+#GDD(file="/var/www/web/server/images/persons.png", type="png", w=670, h=670)
+#file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+png(file="persons.png", w=800, h=800) #local PNG
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 title = "Data uploaded by evaluator"
 subtitle=paste(Sys.Date(),"(YYYY-MM-DD)")
 col.sub="red"
 col.sex=rainbow(2)
 col.level=rainbow(4)
 
-#local
+#local PDF
 #pdf(file="persons.pdf", width=7, height=7)
 #file = "/home/xavier/.local/share/Chronojump/database/chronojump_server_2012-03-07.db"
 #title = ""
@@ -44,12 +44,12 @@ par(new=FALSE, oma=c(1,1,5,0))
 nf <- layout(matrix(c(1,1,2,3,4,5), 3, 2, byrow=FALSE), widths=c(2,1), heights=c(10,10,13), respect=FALSE)
 #layout.show(nf)
 
-dotchart(table(persons$sportF)[order (table(persons$sportF))], 
labels=strtrim(levels(persons$sportF),15)[order (table(persons$sportF))], main="Sport",cex=.6)
+dotchart(table(persons$sportF)[order (table(persons$sportF))], 
labels=strtrim(levels(persons$sportF),15)[order (table(persons$sportF))], main="Sport",cex=.8)
 abline(v=seq(from=0,to=max(table(persons$sportF)),by=10),col = "lightgray", lty=3)
 #dotchart(table(persons$speciallityF), labels=levels(persons$speciallityF), main="athletics speciallities")
 #SPECIALLITIES fer amb un altre select i nomes d'atletisme
 
-dotchart(table(persons$countryF)[order (table(persons$countryF))], 
labels=strtrim(levels(persons$countryF),15)[order (table(persons$countryF))], main="Country",cex=.6)
+dotchart(table(persons$countryF)[order (table(persons$countryF))], 
labels=strtrim(levels(persons$countryF),15)[order (table(persons$countryF))], main="Country",cex=.8)
 abline(v=seq(from=0,to=max(table(persons$countryF)),by=25),col = "lightgray", lty=3)
 
 pie(table(persons$sexF), labels=levels(persons$sexF), main="Gender", col=col.sex)
@@ -64,7 +64,7 @@ hist(ages$years, breaks=10, main="Age", xlab="Years (at session day)")
 
 par(new=TRUE)
 plot(-1,type="n",axes=F,xlab='',ylab='')
-title(main=title, sub=subtitle, cex.sub = 0.75, font.sub = 3, col.sub = col.sub)
+title(main=title, sub=subtitle, cex.sub = 0.8, font.sub = 3, col.sub = col.sub)
 
 dev.off()
 
diff --git a/chronojump_server/r-sqlite/tf_by_age.R b/chronojump_server/r-sqlite/tf_by_age.R
index de4bc19..9397c0f 100644
--- a/chronojump_server/r-sqlite/tf_by_age.R
+++ b/chronojump_server/r-sqlite/tf_by_age.R
@@ -1,9 +1,10 @@
-library(GDD)
-GDD(file="/var/www/web/server/images/tf_by_age.png", type="png", w=670, h=670)
+#library(GDD)
+#GDD(file="/var/www/web/server/images/tf_by_age.png", type="png", w=670, h=670)
+png(file="tf_by_age.png", w=800, h=800) #local PNG
 
 library(RSQLite)
 drv = dbDriver("SQLite")
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 con = dbConnect(drv, file)
 
 def.par <- par(no.readonly = TRUE) # save default, for resetting...
diff --git a/chronojump_server/r-sqlite/tf_by_extra_weight.R b/chronojump_server/r-sqlite/tf_by_extra_weight.R
index ed59ba0..f01e1d6 100644
--- a/chronojump_server/r-sqlite/tf_by_extra_weight.R
+++ b/chronojump_server/r-sqlite/tf_by_extra_weight.R
@@ -1,9 +1,10 @@
-library(GDD)
-GDD(file="/var/www/web/server/images/tf_by_extra_weight.png", type="png", w=670, h=670)
+#library(GDD)
+#GDD(file="/var/www/web/server/images/tf_by_extra_weight.png", type="png", w=670, h=670)
+png(file="tf_by_extra_weight.png", w=800, h=800) #local PNG
 
 library(RSQLite)
 drv = dbDriver("SQLite")
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 con = dbConnect(drv, file)
 
 def.par <- par(no.readonly = TRUE) # save default, for resetting...
diff --git a/chronojump_server/r-sqlite/tf_by_jumps_boxplot.R 
b/chronojump_server/r-sqlite/tf_by_jumps_boxplot.R
index b9ba580..3cfa557 100644
--- a/chronojump_server/r-sqlite/tf_by_jumps_boxplot.R
+++ b/chronojump_server/r-sqlite/tf_by_jumps_boxplot.R
@@ -1,9 +1,11 @@
-library(GDD)
-GDD(file="/var/www/web/server/images/tf_by_jumps_boxplot.png", 
-  width = 670, height= 670, ps = 12, type="png")
+#library(GDD)
+#file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+#GDD(file="/var/www/web/server/images/tf_by_jumps_boxplot.png", 
+#  width = 670, height= 670, ps = 12, type="png")
+png(file="tf_by_jumps_boxplot.png", w=800, h=800) #local PNG
 library(RSQLite)
 drv <- dbDriver("SQLite")
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 con <- dbConnect(drv, file)
 
 jumps <- dbGetQuery(con, "SELECT person77.sex, jump.* FROM person77, jump WHERE person77.uniqueID == 
jump.personID")
diff --git a/chronojump_server/r-sqlite/tf_by_level_sex_jumptype.R 
b/chronojump_server/r-sqlite/tf_by_level_sex_jumptype.R
index 64ffe24..a5a0045 100644
--- a/chronojump_server/r-sqlite/tf_by_level_sex_jumptype.R
+++ b/chronojump_server/r-sqlite/tf_by_level_sex_jumptype.R
@@ -1,8 +1,9 @@
-library(GDD)
-GDD(file="/var/www/web/server/images/tf_by_level_sex_jumptype.png", type="png", w=670, h=670)
+#library(GDD)
+#GDD(file="/var/www/web/server/images/tf_by_level_sex_jumptype.png", type="png", w=670, h=670)
+png(file="tf_by_level_sex_jumptype.png", w=800, h=800) #local PNG
 library(RSQLite)
 drv = dbDriver("SQLite")
-file = "/root/.local/share/Chronojump/database/chronojump_server.db"
+file = "~/.local/share/Chronojump/database/chronojump_server_2013-07-05.db"
 con = dbConnect(drv, file)
 
 jumps <- dbGetQuery(con, "SELECT person77.sex AS sex, personSession77.practice AS level, jump.* from 
person77, personSession77, jump WHERE person77.uniqueID == personSession77.personID AND level>=0 AND 
simulated>=0 AND person77.uniqueID == jump.personID")


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]