[Stacomir-commits] r229 - in pkg/stacomir: R inst/config inst/tests/testthat

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 23 16:58:05 CEST 2016


Author: briand
Date: 2016-10-23 16:58:05 +0200 (Sun, 23 Oct 2016)
New Revision: 229

Modified:
   pkg/stacomir/R/BilanEspeces.r
   pkg/stacomir/R/BilanFonctionnementDC.r
   pkg/stacomir/R/BilanFonctionnementDF.r
   pkg/stacomir/R/BilanMigration.r
   pkg/stacomir/R/BilanMigrationConditionEnv.r
   pkg/stacomir/R/BilanMigrationInterAnnuelle.r
   pkg/stacomir/R/BilanMigrationMult.r
   pkg/stacomir/R/Bilan_carlot.r
   pkg/stacomir/R/Bilan_poids_moyen.r
   pkg/stacomir/R/Bilan_stades_pigm.r
   pkg/stacomir/R/Bilan_taille.r
   pkg/stacomir/R/RefAnnee.r
   pkg/stacomir/R/create_generic.r
   pkg/stacomir/R/fn_EcritBilanJournalier.r
   pkg/stacomir/R/fungraph.r
   pkg/stacomir/R/stacomi.r
   pkg/stacomir/R/utilitaires.r
   pkg/stacomir/inst/config/stacomi_manual_launch.r
   pkg/stacomir/inst/tests/testthat/test-00zRefclasses.R
   pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
   pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R
Log:
remove bug for interface BilanMigration 
remove two errors in BilanMigrationMult (one in weight conversion in calcule, one some code forgotten at the beginning of plot)
reset quitte function to working values as most gr interfaces are assigned to .GlobalEnv

Modified: pkg/stacomir/R/BilanEspeces.r
===================================================================
--- pkg/stacomir/R/BilanEspeces.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanEspeces.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -15,7 +15,6 @@
 #' @slot data \code{data.frame}
 #' @slot liste Object of class \code{\link{RefListe-class}} RefListe referential
 #' class choose within a list
-
 #' @include RefDC.r
 #' @include RefListe.r
 #' @section Objects from the Class: Objects can be created by calls of the form
@@ -32,7 +31,7 @@
 #' \code{\linkS4class{BilanMigrationConditionEnv}},
 #' \code{\linkS4class{BilanMigrationInterAnnuelle}},
 #' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @export 
 setClass(Class="BilanEspeces",

Modified: pkg/stacomir/R/BilanFonctionnementDC.r
===================================================================
--- pkg/stacomir/R/BilanFonctionnementDC.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanFonctionnementDC.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -12,17 +12,7 @@
 #' \code{new("BilanFonctionnementDC", ...)}.
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 #' @example inst/examples/bilanFonctionnementDC_example.R
-#' @seealso Other Bilan Class \code{\linkS4class{Bilan_carlot}}
-#' \code{\linkS4class{Bilan_poids_moyen}}, 
-#' \code{\linkS4class{Bilan_stades_pigm}}, \code{\linkS4class{Bilan_taille}}, 
-#' \code{\linkS4class{BilanConditionEnv}}, \code{\linkS4class{BilanEspeces}}, 
-#' \code{\linkS4class{BilanFonctionnementDC}}, 
-#' \code{\linkS4class{BilanFonctionnementDF}}, 
-#' \code{\linkS4class{BilanMigration}}, 
-#' \code{\linkS4class{BilanMigrationConditionEnv}}, 
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}, 
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @export 
 setClass(Class="BilanFonctionnementDC",

Modified: pkg/stacomir/R/BilanFonctionnementDF.r
===================================================================
--- pkg/stacomir/R/BilanFonctionnementDF.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanFonctionnementDF.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -16,19 +16,7 @@
 #' @slot horodatedebut An object of class \code{RefHorodate-class}
 #' @slot horodatefin An object of class \code{RefHorodate-class}
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Class \code{\linkS4class{Bilan_carlot}}
-#' \code{\linkS4class{Bilan_poids_moyen}}
-#' \code{\linkS4class{Bilan_stades_pigm}} 
-#' \code{\linkS4class{Bilan_taille}}
-#' \code{\linkS4class{BilanConditionEnv}} 
-#' \code{\linkS4class{BilanEspeces}}
-#' \code{\linkS4class{BilanFonctionnementDC}}
-#' \code{\linkS4class{BilanFonctionnementDF}}
-#' \code{\linkS4class{BilanMigration}}
-#' \code{\linkS4class{BilanMigrationConditionEnv}}
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @example inst/examples/bilanFonctionnementDF_example.R
 #' @export 

Modified: pkg/stacomir/R/BilanMigration.r
===================================================================
--- pkg/stacomir/R/BilanMigration.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanMigration.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -16,17 +16,7 @@
 #' @note Method \code{plot(...,type="standard")} also calls a function that will write to the database if
 #' a connection to the database is expected.
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Class \code{\linkS4class{Bilan_carlot}}, 
-#' \code{\linkS4class{Bilan_poids_moyen}}, 
-#' \code{\linkS4class{Bilan_stades_pigm}}, \code{\linkS4class{Bilan_taille}}, 
-#' \code{\linkS4class{BilanConditionEnv}}, \code{\linkS4class{BilanEspeces}}, 
-#' \code{\linkS4class{BilanFonctionnementDC}}, 
-#' \code{\linkS4class{BilanFonctionnementDF}}, 
-#' \code{\linkS4class{BilanMigration}}, 
-#' \code{\linkS4class{BilanMigrationConditionEnv}}, 
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}, 
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @example inst/examples/bilanMigration_Arzal.R
 #' @export 
@@ -309,7 +299,7 @@
 		}
 		
 #' Method to print the command line of the object
-#' @param x An object of class BilanMigrationMult
+#' @param x An object of class BilanMigration
 #' @param ... Additional parameters passed to print
 #' @return NULL
 #' @author cedric.briand
@@ -338,10 +328,7 @@
 #' 		\item{plot.type="step"}{creates Cumulated graphs for BilanMigrationMult.  Data are summed per day for different dc taxa and stages}
 #' 		\item{plot.type="multiple"}{Method to overlay graphs for BilanMigrationMult (multiple dc/taxa/stage in the same plot)}
 #' }
-#' @note When plotting the "standard" plot, the user will be prompted to "write" the daily migration and monthly migration in the database.
-#' these entries are necessary to run the Interannual Migration class. If the stacomi has been launched with database_expected=FALSE,
-#' then no entry will be written to the database
-#' @param x An object of class BilanMigrationMult
+#' @param x An object of class BilanMigration
 #' @param y From the formals but missing
 #' @param plot.type One of "standard","step". Defaut to \code{standard} the standard BilanMigration with dc and operation displayed, can also be \code{step} or 
 #' \code{multiple} 
@@ -419,11 +406,6 @@
 									silent)
 						}
 					} # end nrow(data)>0	
-					###########################################""
-					# Writes the daily bilan in the database
-					#########################################
-					database_expected<-get("database_expected",envir=envir_stacomi)
-					if (database_expected) fn_EcritBilanJournalier(bilanMigration,silent)
 				} # end is.null(data)
 				
 				################################################################
@@ -446,12 +428,12 @@
 							heure=FALSE)
 					grdata$Cumsum=cumsum(grdata$Effectif_total)
 					# pour sauvegarder sous excel
-					annee=unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y"))
+					annee=unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y"))[1]
 					dis_commentaire=  as.character(bilanMigration at dc@data$dis_commentaires[bilanMigration at dc@data$dc%in%bilanMigration at dc@dc_selectionne]) 
-					update_geom_defaults("step", aes(size = 3))
+					update_geom_defaults("line", aes(size = 2))
 					
 					p<-ggplot(grdata)+
-							geom_step(aes(x=debut_pas,y=Cumsum,colour=mois))+
+							geom_line(aes(x=debut_pas,y=Cumsum,colour=mois))+
 							ylab(get("msg",envir_stacomi)$BilanMigration.6)+
 							ggtitle(paste(get("msg",envir_stacomi)$BilanMigration.7," ",dis_commentaire,", ",taxon,", ",stade,", ",annee,sep="")) + 
 							theme(plot.title = element_text(size=10,colour="navy"))+
@@ -476,10 +458,15 @@
 				stop("unrecognised plot.type argument, plot.type should either be standard or step")
 			}
 		})
+		
 
-
-
-
+		
+#' handler for  hBilanMigrationgraph
+#' 
+#' Standard BilanMigration graph over time
+#' @param h handler
+#' @param ... additional parameters
+#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 hbilanMigrationgraph = function(h,...) {
 	if (exists("bilanMigration",envir_stacomi)) {
 		bilanMigration<-get("bilanMigration",envir_stacomi)
@@ -490,7 +477,7 @@
 		
 }
 
-#' handler for calcul hBilanMigrationgraph2
+#' handler for hBilanMigrationgraph2
 #' 
 #' Step plot over time
 #' @param h handler
@@ -512,7 +499,6 @@
 #' @param ... Additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 hTableBilanMigration=function(h,...) {
-	hTableBilanMigrationMult=function(h=null,...) {
 		if (exists("bilanMigration",envir_stacomi)) 
 		{
 			bilanMigration<-get("bilanMigration",envir_stacomi)
@@ -522,7 +508,7 @@
 			funout(get("msg",envir_stacomi)$BilanMigration.5,arret=TRUE)
 		}
 		summary(bilanMigration)
-	}
+	
 }
 
 #' summary for bilanMigration 
@@ -543,7 +529,10 @@
 
 
 #' handler hBilanMigrationwrite
-#' Allows the saving of daily and monthly counts in the database, this method is also called from hbilanMigrationgraph
+#' Allows the saving of daily and monthly counts in the database
+#' @note these entries are necessary to run the Interannual Migration class. 
+#' then no entry will be written to the database
+
 #' @param h a handler
 #' @param ... Additional parameters
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
@@ -554,5 +543,11 @@
 		funout(get("msg",envir_stacomi)$BilanMigration.5,arret=TRUE)
 	}
 	# ecriture du bilan journalier, ecrit aussi le bilan mensuel
-	fn_EcritBilanJournalier(bilanMigration,silent=FALSE)
+	database_expected<-get("database_expected",envir=envir_stacomi)
+	if (database_expected) {
+		fn_EcritBilanJournalier(bilanMigration,silent=TRUE)
+	}	else {
+		funout("no bilan written to database : database_expected argument=FALSE")
+	}
+	
 }
\ No newline at end of file

Modified: pkg/stacomir/R/BilanMigrationConditionEnv.r
===================================================================
--- pkg/stacomir/R/BilanMigrationConditionEnv.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanMigrationConditionEnv.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -16,17 +16,7 @@
 #' \code{"BilanConditionEnv"} The environmental overview}\item{:}{Object of
 #' class \code{"BilanConditionEnv"} The environmental overview} }
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Class \code{\linkS4class{Bilan_carlot}}
-#' \code{\linkS4class{Bilan_poids_moyen}}
-#' \code{\linkS4class{Bilan_stades_pigm}} \code{\linkS4class{Bilan_taille}}
-#' \code{\linkS4class{BilanConditionEnv}} \code{\linkS4class{BilanEspeces}}
-#' \code{\linkS4class{BilanFonctionnementDC}}
-#' \code{\linkS4class{BilanFonctionnementDF}}
-#' \code{\linkS4class{BilanMigration}}
-#' \code{\linkS4class{BilanMigrationConditionEnv}}
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @export 
 setClass(Class="BilanMigrationConditionEnv",representation=

Modified: pkg/stacomir/R/BilanMigrationInterAnnuelle.r
===================================================================
--- pkg/stacomir/R/BilanMigrationInterAnnuelle.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanMigrationInterAnnuelle.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -5,10 +5,7 @@
 #' 
 #' 
 #' @include RefAnnee.r
-#' @section Objects from the Class: Objects can be created by calls of the form
-#' 	\code{new("BilanMigrationConditionEnv",
-#' 	bilanMigration=new("BilanMigration"),
-#' 	bilanConditionEnv=new("BilanConditionEnv"))}.  
+
 #' @slot dc Object of class \code{\link{RefDC-class}}, the counting device
 #' @slot data Object of class \code{"data.frame"} data for bilan lot 
 #' @slot taxons An object of class \code{\link{RefTaxon-class}}
@@ -18,19 +15,7 @@
 #' refAnnee allows to choose last year of the Bilan
 #' 
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Class \code{\linkS4class{Bilan_carlot}}, 
-#' 	\code{\linkS4class{Bilan_poids_moyen}}, 
-#' 	\code{\linkS4class{Bilan_stades_pigm}}, 
-#' 	\code{\linkS4class{Bilan_taille}}, 
-#' 	\code{\linkS4class{BilanConditionEnv}}, 
-#' 	\code{\linkS4class{BilanEspeces}}, 
-#' 	\code{\linkS4class{BilanFonctionnementDC}}, 
-#' 	\code{\linkS4class{BilanFonctionnementDF}}, 
-#' 	\code{\linkS4class{BilanMigration}},  
-#' 	\code{\linkS4class{BilanMigrationConditionEnv}}, 
-#' 	\code{\linkS4class{BilanMigrationInterAnnuelle}}, 
-#' 	\code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @export
 setClass(Class="BilanMigrationInterAnnuelle",representation=

Modified: pkg/stacomir/R/BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMult.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/BilanMigrationMult.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -24,6 +24,7 @@
 #' @slot coef_conversion A data frame of daily weight to number conversion coefficients, filled in by the connect
 #' method if any weight are found in the data slot.
 #' @slot time.sequence A POSIXt time sequence
+#' @family Bilan Objects
 #' @keywords classes
 #' @export
 #' @example inst/examples/bilanMigrationMult_Arzal.R
@@ -182,12 +183,11 @@
 #' @return BilanMigrationMult with a list in calcdata, one for each triplet (dc/taxa/stage) with data
 #' @export
 setMethod("calcule",signature=signature("BilanMigrationMult"),definition=function(object,negative=FALSE,silent=FALSE){ 
+			# bilanMigrationMult<-bMM_Arzal
 			if (!silent) funout(get("msg",envir=envir_stacomi)$BilanMigration.2)
 			bilanMigrationMult<-object
 			
-			bilanMigrationMult at data$time.sequence=difftime(bilanMigrationMult at data$ope_date_fin,
-					bilanMigrationMult at data$ope_date_debut,
-					units="days")
+
 			debut=bilanMigrationMult at pasDeTemps@dateDebut
 			fin=DateFin(bilanMigrationMult at pasDeTemps)
 			time.sequence<-seq.POSIXt(from=debut,to=fin,
@@ -223,16 +223,18 @@
 					#----------------------
 					#bilan simple
 					#----------------------
-					data<-fun_bilanMigrationMult(time.sequence = time.sequence,datasub=datasub,negative=negative)
-					data$taux_d_echappement=-1
-					data$coe_valeur_coefficient=NA
+					mydata<-fun_bilanMigrationMult(time.sequence = time.sequence,datasub=datasub,negative=negative)
+					mydata$taux_d_echappement=-1
+					mydata$coe_valeur_coefficient=NA
 					contient_poids<-"poids"%in%datasub$type_de_quantite
 					if (contient_poids){
+						# a ce stade les données contenues dans coe_valeur_coefficient sont nulles on enlève la colonne avant le merge
+						mydata<-mydata[,-match("coe_valeur_coefficient",colnames(mydata))]
 						coe<-bilanMigrationMult at coef_conversion[,c("coe_date_debut","coe_valeur_coefficient")]
-						data$coe_date_debut<-as.Date(data$debut_pas)
-						data<-merge(data,coe,by="coe_date_debut")
-						data<-data[,-1] # removing coe_date_debut
-						data <-fun_weight_conversion(tableau=data,time.sequence=bilanMigrationMult at time.sequence,silent)
+						mydata$coe_date_debut<-as.Date(mydata$debut_pas)
+						mydata2<-merge(mydata,coe,by="coe_date_debut")
+						mydata2<-mydata2[,-match("coe_date_debut",colnames(mydata2))] # removing coe_date_debut
+						data <-fun_weight_conversion(tableau=mydata2,time.sequence=bilanMigrationMult at time.sequence,silent)
 					}
 					lestableaux[[stringr::str_c("dc_",dic)]][["data"]]<-data
 					lestableaux[[stringr::str_c("dc_",dic)]][["method"]]<-"sum"
@@ -596,6 +598,7 @@
 	bilanMigrationMult<-get("bilanMigrationMult",envir=envir_stacomi)
 	bilanMigrationMult<-charge(bilanMigrationMult)
 	# charge loads the method connect
+	bilanMigrationMult<-connect(bilanMigrationMult)
 	bilanMigrationMult<-calcule(bilanMigrationMult)
 }
 

Modified: pkg/stacomir/R/Bilan_carlot.r
===================================================================
--- pkg/stacomir/R/Bilan_carlot.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/Bilan_carlot.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -15,19 +15,7 @@
 #' @section Objects from the Class: Objects can be created by calls of the form
 #' \code{new("Bilan_carlot", ...)}
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Class \code{\linkS4class{Bilan_carlot}}
-#' \code{\linkS4class{Bilan_poids_moyen}}
-#' \code{\linkS4class{Bilan_stades_pigm}} 
-#' \code{\linkS4class{Bilan_taille}}
-#' \code{\linkS4class{BilanConditionEnv}} 
-#' \code{\linkS4class{BilanEspeces}}
-#' \code{\linkS4class{BilanFonctionnementDC}}
-#' \code{\linkS4class{BilanFonctionnementDF}}
-#' \code{\linkS4class{BilanMigration}}
-#' \code{\linkS4class{BilanMigrationConditionEnv}}
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
+#' @family Bilan Objects
 #' @keywords classes
 #' @example inst/examples/bilancarlot_example.R
 #' @export 

Modified: pkg/stacomir/R/Bilan_poids_moyen.r
===================================================================
--- pkg/stacomir/R/Bilan_poids_moyen.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/Bilan_poids_moyen.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -26,21 +26,8 @@
 #' in the stacomi database are samples with a non null value for parent sample. Migration
 #' counts are never made on subsamples but those can be integrated to calculate mean weights.
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso 
-#' Other Bilan Classes \code{\linkS4class{Bilan_carlot}}
-#' \code{\linkS4class{Bilan_poids_moyen}}
-#' \code{\linkS4class{Bilan_stades_pigm}} 
-#' \code{\linkS4class{Bilan_taille}}
-#' \code{\linkS4class{BilanConditionEnv}} 
-#' \code{\linkS4class{BilanEspeces}}
-#' \code{\linkS4class{BilanFonctionnementDC}}
-#' \code{\linkS4class{BilanFonctionnementDF}}
-#' \code{\linkS4class{BilanMigration}}
-#' \code{\linkS4class{BilanMigrationConditionEnv}}
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object 
-#'  @keywords classes
+#' @family Bilan Objects
+#' @keywords classes
 #' @examples
 #'  \dontrun{
 #' showClass("Bilan_poids_moyen")

Modified: pkg/stacomir/R/Bilan_stades_pigm.r
===================================================================
--- pkg/stacomir/R/Bilan_stades_pigm.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/Bilan_stades_pigm.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -35,19 +35,7 @@
 #' @section Objects from the Class: Objects can be created by calls of the form
 #' \code{new("Bilan_stades_pigm", ...)}.
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Classes \code{\linkS4class{Bilan_carlot}}
-#' \code{\linkS4class{Bilan_poids_moyen}}
-#' \code{\linkS4class{Bilan_stades_pigm}} 
-#' \code{\linkS4class{Bilan_taille}}
-#' \code{\linkS4class{BilanConditionEnv}} 
-#' \code{\linkS4class{BilanEspeces}}
-#' \code{\linkS4class{BilanFonctionnementDC}}
-#' \code{\linkS4class{BilanFonctionnementDF}}
-#' \code{\linkS4class{BilanMigration}}
-#' \code{\linkS4class{BilanMigrationConditionEnv}}
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}
-#' \code{\linkS4class{BilanMigrationPar}} 
-#' \code{\link{fnstade}}
+#' @family Bilan Objects
 #' @keywords classes
 #' @references BRIAND C., FATIN D., CICCOTTI E. and LAMBERT P., 2005. A
 #' stage-structured model to predict the effect of temperature and salinity on

Modified: pkg/stacomir/R/Bilan_taille.r
===================================================================
--- pkg/stacomir/R/Bilan_taille.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/Bilan_taille.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -26,17 +26,7 @@
 #' @section Objects from the Class: Objects can be created by calls of the form
 #' \code{new("Bilan_taille", ...)}
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @seealso Other Bilan Classes \code{\linkS4class{Bilan_carlot}}, 
-#' \code{\linkS4class{Bilan_poids_moyen}}, 
-#' \code{\linkS4class{Bilan_stades_pigm}}, \code{\linkS4class{Bilan_taille}}, 
-#' \code{\linkS4class{BilanConditionEnv}}, \code{\linkS4class{BilanEspeces}}, 
-#' \code{\linkS4class{BilanFonctionnementDC}}, 
-#' \code{\linkS4class{BilanFonctionnementDF}}, 
-#' \code{\linkS4class{BilanMigration}}, 
-#' \code{\linkS4class{BilanMigrationConditionEnv}}, 
-#' \code{\linkS4class{BilanMigrationInterAnnuelle}}, 
-#' \code{\linkS4class{BilanMigrationPar}}
-#' @concept Bilan Object
+#' @family Bilan Objects
 #' @keywords classes 
 #' @examples
 #' 

Modified: pkg/stacomir/R/RefAnnee.r
===================================================================
--- pkg/stacomir/R/RefAnnee.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/RefAnnee.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -22,20 +22,6 @@
 #' \code{new("RefAnnee", data=data.frame(), annee_selectionnee=numeric())}.
 #' @slot data A \code{data.frame} with the list of possible years selected as numerics
 #' @slot annee_selectionnee A numeric vector
-#' @seealso Other referential classes 
-#' \code{\linkS4class{RefAnnee}}
-#' \code{\linkS4class{RefCheckBox}} 
-#' \code{\linkS4class{RefChoix}}
-#' \code{\linkS4class{RefCoe}}
-#' \code{\linkS4class{RefDC}}
-#' \code{\linkS4class{RefDF}} 
-#' \code{\linkS4class{RefListe}}
-#' \code{\linkS4class{Refpar}} 
-#' \code{\linkS4class{Refparqual}}
-#' \code{\linkS4class{Refparquan}} 
-#' \code{\linkS4class{RefStades}} 
-#' \code{\linkS4class{RefStationMesure}}
-#' \code{\linkS4class{RefTaxon}}
 #' @keywords classes
 #' @family Referential objects
 #' @author cedric.briand"at"eptb-vilaine.fr

Modified: pkg/stacomir/R/create_generic.r
===================================================================
--- pkg/stacomir/R/create_generic.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/create_generic.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -50,6 +50,11 @@
 #' @param object Object
 #' @param ... Additional parms
 #' @author cedric.briand
+setGeneric("write_database",def=function(object,...) standardGeneric("write_database"))
+#' Generic method getvalue
+#' @param object Object
+#' @param ... Additional parms
+#' @author cedric.briand
 setGeneric("getvalue",def=function(object,...) standardGeneric("getvalue"))
 #' Generic method getvalue
 #' @param object Object

Modified: pkg/stacomir/R/fn_EcritBilanJournalier.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanJournalier.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/fn_EcritBilanJournalier.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -36,7 +36,7 @@
 			bilanMigration at dc@dc_selectionne,
 			bilanMigration at taxons@data$tax_code,
 			bilanMigration at stades@data$std_code,
-			unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y")), # une valeur
+			unique(strftime(as.POSIXlt(bilanMigration at time.sequence),"%Y"))[1], # une valeur
 			rep(as.character(jour_dans_lannee_non_nuls),ncol(data[,c("MESURE","CALCULE","EXPERT","PONCTUEL","Effectif_total","taux_d_echappement","coe_valeur_coefficient")])),
 			utils::stack(data[,c("MESURE","CALCULE","EXPERT","PONCTUEL","Effectif_total","taux_d_echappement","coe_valeur_coefficient")]),  
 			format(Sys.time(), "%Y-%m-%d %H:%M:%S"),

Modified: pkg/stacomir/R/fungraph.r
===================================================================
--- pkg/stacomir/R/fungraph.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/fungraph.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -22,7 +22,7 @@
 	#browser() 
 	#cat("fungraph")
 	if (is.null(dc)) dc=bilanMigration at dc@dc_selectionne[1]
-	annee=unique(strftime(as.POSIXlt(time.sequence),"%Y"))
+	annee=unique(strftime(as.POSIXlt(time.sequence),"%Y"))[1]
 	mois= months(time.sequence)
 	jour= strftime(as.POSIXlt(time.sequence),"%j")
 	jmois=strftime(as.POSIXlt(time.sequence),"%d")

Modified: pkg/stacomir/R/stacomi.r
===================================================================
--- pkg/stacomir/R/stacomi.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/stacomi.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -394,7 +394,8 @@
 		dir.create(path.expand(get("datawd",envir=envir_stacomi)))
 	}
 	
-	col.sortie=rep(c("pink","purple","red","orange","green","blue","cyan","magenta"),20) # couleurs pour le texte
+	col.sortie=rep(c("pink","purple","red","orange","green","blue","cyan","magenta"),20)  # couleurs pour le texte
+	# attention doivent être standard
 	assign("col.sortie",col.sortie,.GlobalEnv)
 	nbligne=0
 	assign("nbligne",nbligne,.GlobalEnv)

Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/R/utilitaires.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -5,9 +5,16 @@
 #' @param \dots additional arguments passed to the function
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 quitte=function(...){
-	if (exists("ggroupboutonsbas",envir=envir_stacomi)) delete(ggroupboutons,ggroupboutonsbas)
-     rm
-	if (exists("group",envir=envir_stacomi)) {
+	# all gWidgets object are assigned in .GlobalEnv, the other are in envir_stacomi
+	if (exists("ggroupboutonsbas",envir=.GlobalEnv)) 
+		# delete for something added with the add method
+		delete(ggroupboutons,ggroupboutonsbas)
+
+	if (exists("notebook",envir=envir_stacomi))
+		dispose(notebook)
+	
+
+	if (exists("group",envir=.GlobalEnv)) {
 		delete(ggroupboutons,group) 
 		rm(group,envir= .GlobalEnv)
 	}
@@ -19,8 +26,8 @@
 			rm(list=miettes,envir=envir_stacomi)
 		}      
 	}
-	if (length(ls(pattern="frame",envir=envir_stacomi))!=0) {
-		rm(list=ls(pattern="frame",envir=envir_stacomi),envir=envir_stacomi)
+	if (length(ls(pattern="frame",envir=.GlobalEnv))!=0) {
+		rm(list=ls(pattern="frame",envir=.GlobalEnv),envir=.GlobalEnv)
 	}
 	if (exists("g")) rm(g)
 }

Modified: pkg/stacomir/inst/config/stacomi_manual_launch.r
===================================================================
--- pkg/stacomir/inst/config/stacomi_manual_launch.r	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/inst/config/stacomi_manual_launch.r	2016-10-23 14:58:05 UTC (rev 229)
@@ -28,7 +28,6 @@
 source("utilitaires.r") # contient  funout (pour ecrire dans la console) et filechoose
 source("messages.R")
 source("fn_table_per_dis.r") 
-source("fn_sql_dis.r")
 source("funtraitementdate.r")  
 #source("vector_to_listsql.r")
 source("funstatJournalier.r") 

Modified: pkg/stacomir/inst/tests/testthat/test-00zRefclasses.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00zRefclasses.R	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/inst/tests/testthat/test-00zRefclasses.R	2016-10-23 14:58:05 UTC (rev 229)
@@ -30,7 +30,7 @@
 			expect_error(refHorodate<-choice_c(refHorodate,	
 							horodate="2013 01 01"))	
 			options(warn = 2)
-			rm("envir_stacomi",envir =.GlobalEnv)
+			
 		})
 
 context("RefDF")

Modified: pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R	2016-10-23 14:58:05 UTC (rev 229)
@@ -111,4 +111,33 @@
 			data("bM_Arzal")
 			expect_output(print(bM_Arzal), "bilanMigration=choice_c",info = NULL)
 			rm("envir_stacomi",envir =.GlobalEnv)
+		})
+
+
+
+test_that("test example for fd80",
+		{
+			stacomi(gr_interface=FALSE,
+					login_window=FALSE,
+					database_expected=TRUE)	
+			# overriding user schema
+			baseODBC<-get("baseODBC",envir=envir_stacomi)
+			baseODBC[c(2,3)]<-rep("fd80",2)
+			assign("baseODBC",baseODBC,envir_stacomi)
+			sch<-get("sch",envir=envir_stacomi) # "iav."
+			assign("sch","fd80.",envir_stacomi)
+			# this chunk is not launched from examples but loads the bM_Arzal dataset if connection works	
+			bM_EclusierVaux=new("BilanMigration")
+			bM_EclusierVaux=choice_c(bM_EclusierVaux,
+					dc=6,
+					taxons=c("Anguilla anguilla"),
+					stades=c("AGG"),
+					datedebut="2016-01-01",
+					datefin="2016-12-31")
+			bM_EclusierVaux<-charge(bM_EclusierVaux,silent=TRUE)
+			bM_EclusierVaux<-connect(bM_EclusierVaux,silent=TRUE)
+			bM_EclusierVaux<-calcule(bM_EclusierVaux)
+			plot(bM_EclusierVaux)
+			summary(bM_EclusierVaux)
+			rm("envir_stacomi",envir =.GlobalEnv)
 		})
\ No newline at end of file

Modified: pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R	2016-10-05 12:43:07 UTC (rev 228)
+++ pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R	2016-10-23 14:58:05 UTC (rev 229)
@@ -12,7 +12,7 @@
 			expect_true(nrow(result)>0)
 		})
 
-test_that("Test an instance of Bilan_opecar loaded with choice_c",{
+test_that("Test an instance of Bilan_carlot loaded with choice_c",{
 			require(stacomiR)
 			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			# overriding user schema to point to iav
@@ -40,7 +40,7 @@
 		})
 
 
-test_that("Test methods in Bilan_opecar",{
+test_that("Test methods in Bilan_carlot",{
 			require(stacomiR)
 			stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
 			# overriding user schema to point to iav



More information about the Stacomir-commits mailing list