[Stacomir-commits] r439 - in pkg/stacomir: . R inst/config man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 13 08:36:15 CEST 2017


Author: briand
Date: 2017-07-13 08:36:15 +0200 (Thu, 13 Jul 2017)
New Revision: 439

Modified:
   pkg/stacomir/DESCRIPTION
   pkg/stacomir/NAMESPACE
   pkg/stacomir/R/report_mig_interannual.R
   pkg/stacomir/inst/config/generate_Roxygen2.R
   pkg/stacomir/man/envir_stacomi.Rd
   pkg/stacomir/man/summary-report_mig_interannual-method.Rd
Log:
changes to the summary-report_mig_interannual-method 

Changes to allow for a summary for multiple DC

Modified: pkg/stacomir/DESCRIPTION
===================================================================
--- pkg/stacomir/DESCRIPTION	2017-06-28 16:42:49 UTC (rev 438)
+++ pkg/stacomir/DESCRIPTION	2017-07-13 06:36:15 UTC (rev 439)
@@ -9,7 +9,8 @@
     monitoring. It is a part of the 'STACOMI' open source project developed in
     France by the French Agency for Biodiversity (AFB) institute to centralize
     data obtained by fish pass monitoring. Version 0.5.3 is available in French and
-    English. See <http://stacomir.r-forge.r-project.org/> for more information on 'STACOMI'.
+    English. See <http://stacomir.r-forge.r-project.org/> for more information on
+    'STACOMI'.
 License: GPL (>= 2)
 URL: http://stacomir.r-forge.r-project.org/
 Collate:
@@ -80,7 +81,7 @@
     stacomirtools,
     RODBC
 Imports:
-	magrittr,
+    magrittr,
     intervals,
     RColorBrewer,
     stringr,

Modified: pkg/stacomir/NAMESPACE
===================================================================
--- pkg/stacomir/NAMESPACE	2017-06-28 16:42:49 UTC (rev 438)
+++ pkg/stacomir/NAMESPACE	2017-07-13 06:36:15 UTC (rev 439)
@@ -16,7 +16,6 @@
 export(split_per_day)
 export(stacomi)
 export(vector_to_listsql)
-export(envir_stacomi)
 exportClasses(report_annual)
 exportClasses(report_dc)
 exportClasses(report_df)

Modified: pkg/stacomir/R/report_mig_interannual.R
===================================================================
--- pkg/stacomir/R/report_mig_interannual.R	2017-06-28 16:42:49 UTC (rev 438)
+++ pkg/stacomir/R/report_mig_interannual.R	2017-07-13 06:36:15 UTC (rev 439)
@@ -493,7 +493,7 @@
 	  dat[,timesplit]<-dat$jour #
 	  for (j in 1:(length(seq_timesplit)-1)){
 		dat[dat$jour >= seq_timesplit[j] & dat$jour < seq_timesplit[j+1], timesplit] <-
-             seq_timesplit[j]
+            seq_timesplit[j]
 	  }
 	  dat[dat$jour>=seq_timesplit[length(seq_timesplit)],timesplit]<-seq_timesplit[length(seq_timesplit)]
 	  dat[,"interv"]<-paste(dat[,"annee"],dat[,timesplit])
@@ -514,7 +514,7 @@
 		dat=rbind(dat,dat0)
 	  } # end for
 	}
-		
+	
 	maxdat<-suppressWarnings(tapply(dat$valeur,as.character(dat[,timesplit]),max,na.rm=TRUE))
 	mindat<-suppressWarnings(tapply(dat$valeur,as.character(dat[,timesplit]),min,na.rm=TRUE))
 	meandat<-suppressWarnings(tapply(dat$valeur,as.character(dat[,timesplit]),mean,na.rm=TRUE))
@@ -591,7 +591,7 @@
 		  print(g)
 		  assign("g",g,envir=envir_stacomi)
 		  if (!silent) funout(gettext("Writing the graphical object into envir_stacomi environment : write g=get('g',envir_stacomi)\n",domain="R-stacomiR"))
-		#----------------------------------------------
+		          #----------------------------------------------
 		} else if (plot.type=="standard"){
 		  dat=report_mig_interannual at data
 		  if (silent==FALSE){
@@ -656,7 +656,7 @@
 		  #################
 		  # calculation of cumusums
 		  ###################
-		  		 
+		  
 		  for (an in unique(dat$annee)){
 			# an=as.character(unique(dat$annee)) ;an<-an[1]
 			dat[dat$annee==an,"cumsum"] <- cumsum(dat[dat$annee==an,"valeur"])
@@ -665,7 +665,7 @@
 		  dat$cumsum <- dat$cumsum/dat$total_annuel
 		  dat$jour <- as.Date(dat$jour)
 		  dat$annee <- as.factor(dat$annee)
-		  		  
+		  
 		  #################
 		  # plot
 		  ###################
@@ -765,19 +765,19 @@
 			# pb the limit truncs the value
 			g <- g+ylab("effectif")
 			cols <- c( "max" = "#000080",
-                       "min" = "#BF0000",
-                     ">=moy" = "darkgreen",
-                      "<moy" = "darkorange",
-                  "hist_mean"="black",
-                 "hist_range"="grey",
-                          "?"="darkviolet")
+                "min" = "#BF0000",
+                ">=moy" = "darkgreen",
+                "<moy" = "darkorange",
+                "hist_mean"="black",
+                "hist_range"="grey",
+                "?"="darkviolet")
 			fills <- c("max" = "blue",
-                       "min" = "red",
-                     ">=moy" = "green",
-                      "<moy" = "orange",
-                  "hist_mean"="black",
-                 "hist_range"="grey",
-                          "?"="violet")
+                "min" = "red",
+                ">=moy" = "green",
+                "<moy" = "orange",
+                "hist_mean"="black",
+                "hist_range"="grey",
+                "?"="violet")
 			
 			g <- g+scale_colour_manual(name=the_choice,values=cols,
                 limits=c("min","max","<moy",">=moy","hist_mean","hist_range","?"))
@@ -1107,6 +1107,7 @@
 #' @param ... Additional parameters (not used there)
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @aliases summary.report_mig_interannual
+#' @return A list, one element per DC
 #' @export
 setMethod("summary",signature=signature(object="report_mig_interannual"),definition=function(object,silent=FALSE,...){
 	  # table generated with funtable
@@ -1119,32 +1120,39 @@
 	  dat = dat[,-1]
 	  tmp = dat$Jour
 	  DC = object at dc@dc_selectionne
+      dat<-chnames(dat,"Jour","debut_pas")
 	  # debut_pas must be column name in tableau
-	  dat<-chnames(dat,"Jour","debut_pas")
-	  funtable(tableau=dat,
-		  time.sequence=tmp,
-		  taxa=object at taxa@data$tax_nom_latin,
-		  stage=object at stage@data$std_libelle,
-		  DC,
-		  resum=NULL,
-		  silent=silent)
-	  # Summary statistics
-	  dat=object at data
-	  if (silent==FALSE){
-		the_choice=as.numeric(select.list(choices=as.character(unique(dat$bjo_annee )[order(unique(dat$bjo_annee ))]),
-				preselect=as.character(max(dat$bjo_annee )),
-				"choice annee",multiple=FALSE))
-	  } else {
-		the_choice=max((dat$bjo_annee))
-	  }
-	  dat<-fun_report_mig_interannual(dat,timesplit="mois")
-	  colnames(dat)[colnames(dat)=="maxtab"]<-"max"
-	  colnames(dat)[colnames(dat)=="mintab"]<-"min"
-	  dat<-dat[dat$annee==the_choice,]
-	  dat$mois=strftime(dat$mois,"%b")
-	  dat$moyenne<-round(dat$moyenne)
-	  dat<-dat[,c("annee","mois","min","moyenne","max","valeur")]
-	  colnames(dat)<-c("annee","mois","min","mean","max","valeur")
-	  return(dat)
+      listDC<-list()
+      for (i in 1:length(DC)){
+        # this table will write an html table of data
+	         funtable(tableau=dat[dat$bjo_dis_identifiant==DC,],
+		              time.sequence=tmp,
+		              taxa=object at taxa@data$tax_nom_latin,
+		              stage=object at stage@data$std_libelle,
+		              DC[i],
+		              resum=NULL,
+		              silent=silent)
+	          # Summary statistics
+	          dat=object at data
+	          if (silent==FALSE){
+		          the_choice=as.numeric(select.list(choices=as.character(unique(dat$bjo_annee )[order(unique(dat$bjo_annee ))]),
+				                  preselect=as.character(max(dat$bjo_annee )),
+				                  "choice annee",multiple=FALSE))
+	          } else {
+		          the_choice=max((dat$bjo_annee))
+	          }
+              # we use the function that split data per time stamp to generate the full sequence of monthly data
+	          dat<-fun_report_mig_interannual(dat[dat$bjo_dis_identifiant==DC[i],],timesplit="mois")
+              # then we extract only current year for summary
+	          colnames(dat)[colnames(dat)=="maxtab"]<-"max"
+	          colnames(dat)[colnames(dat)=="mintab"]<-"min"
+	          dat<-dat[dat$annee==the_choice,]
+	          dat$mois=strftime(dat$mois,"%b")
+	          dat$moyenne<-round(dat$moyenne)
+	          dat<-dat[,c("annee","mois","min","moyenne","max","valeur")]
+	          colnames(dat)<-c("annee","mois","min","mean","max","valeur")
+              listDC[[as.character(DC[i])]]<-dat
+          }# end for
+	  return(listDC)
 	})
 

Modified: pkg/stacomir/inst/config/generate_Roxygen2.R
===================================================================
--- pkg/stacomir/inst/config/generate_Roxygen2.R	2017-06-28 16:42:49 UTC (rev 438)
+++ pkg/stacomir/inst/config/generate_Roxygen2.R	2017-07-13 06:36:15 UTC (rev 439)
@@ -43,8 +43,8 @@
 
 # using roxygen with stacomirtools
 #roxygen2::roxygenise("C:/Users/logrami/workspace/stacomir/pkg/stacomir");warnings()[1:10]
-require(Rd2roxygen)
-setwd("C:/workspace/stacomir/pkg")
-Rd2roxygen(pkg="stacomirtools")
+#require(Rd2roxygen)
+#setwd("C:/workspace/stacomir/pkg")
+#Rd2roxygen(pkg="stacomirtools")
 
     
\ No newline at end of file

Modified: pkg/stacomir/man/envir_stacomi.Rd
===================================================================
--- pkg/stacomir/man/envir_stacomi.Rd	2017-06-28 16:42:49 UTC (rev 438)
+++ pkg/stacomir/man/envir_stacomi.Rd	2017-07-13 06:36:15 UTC (rev 439)
@@ -5,7 +5,7 @@
 \alias{envir_stacomi}
 \title{Environment where most objects from the package are stored and then loaded
 by the charge method}
-\format{An object of class \code{environment} of length 9.}
+\format{An object of class \code{environment} of length 0.}
 \usage{
 envir_stacomi
 

Modified: pkg/stacomir/man/summary-report_mig_interannual-method.Rd
===================================================================
--- pkg/stacomir/man/summary-report_mig_interannual-method.Rd	2017-06-28 16:42:49 UTC (rev 438)
+++ pkg/stacomir/man/summary-report_mig_interannual-method.Rd	2017-07-13 06:36:15 UTC (rev 439)
@@ -18,6 +18,9 @@
 
 \item{...}{Additional parameters (not used there)}
 }
+\value{
+A list, one element per DC
+}
 \description{
 summary for report_mig_interannual
 provides summary statistics for the latest year (if silent=TRUE), or the year selected in the interface,



More information about the Stacomir-commits mailing list