[Stacomir-commits] r205 - / pkg/stacomir pkg/stacomir/R pkg/stacomir/data pkg/stacomir/examples/02_BilanMigration pkg/stacomir/inst/config pkg/stacomir/inst/tests/testthat pkg/stacomir/man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Sep 10 14:52:27 CEST 2016
Author: briand
Date: 2016-09-10 14:52:26 +0200 (Sat, 10 Sep 2016)
New Revision: 205
Added:
pkg/stacomir/.Rinstignore
pkg/stacomir/data/calcmig.rda
pkg/stacomir/man/DateFin-PasDeTemps-method.Rd
pkg/stacomir/man/DateFin.Rd
pkg/stacomir/man/calcmig.Rd
pkg/stacomir/man/choice-PasDeTemps-method.Rd
pkg/stacomir/man/currentDateDebut-PasDeTemps-method.Rd
pkg/stacomir/man/currentDateDebut.Rd
pkg/stacomir/man/currentDateFin-PasDeTemps-method.Rd
pkg/stacomir/man/currentDateFin.Rd
pkg/stacomir/man/getAnnees-PasDeTemps-method.Rd
pkg/stacomir/man/getAnnees.Rd
pkg/stacomir/man/getLibellesPas-PasDeTemps-method.Rd
pkg/stacomir/man/getLibellesPas.Rd
pkg/stacomir/man/getdateDebut-PasDeTemps-method.Rd
pkg/stacomir/man/getdateDebut.Rd
pkg/stacomir/man/getnoPasCourant-PasDeTemps-method.Rd
pkg/stacomir/man/getnoPasCourant.Rd
pkg/stacomir/man/print-BilanMigration-method.Rd
pkg/stacomir/man/setdateDebut-PasDeTemps-method.Rd
pkg/stacomir/man/setdateDebut.Rd
pkg/stacomir/man/suivant-PasDeTemps-method.Rd
pkg/stacomir/man/suivant.Rd
Removed:
. Rinstignore
pkg/stacomir/inst/config/calcmig.csv
Modified:
pkg/stacomir/NAMESPACE
pkg/stacomir/R/BilanFonctionnementDF.r
pkg/stacomir/R/BilanMigration.r
pkg/stacomir/R/BilanMigrationMult.r
pkg/stacomir/R/PasdeTemps.r
pkg/stacomir/R/RefDF.r
pkg/stacomir/R/RefHorodate.r
pkg/stacomir/R/RefPoidsMoyenPeche.r
pkg/stacomir/R/data.r
pkg/stacomir/R/fn_EcritBilanJournalier.r
pkg/stacomir/R/fn_EcritBilanMensuel.r
pkg/stacomir/R/fungraph.r
pkg/stacomir/R/utilitaires.r
pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R
pkg/stacomir/inst/config/generate_data.R
pkg/stacomir/inst/tests/testthat/test-00stacomir.R
pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R
pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R
pkg/stacomir/man/BilanMigration-class.Rd
pkg/stacomir/man/choice_c-BilanFonctionnementDF-method.Rd
pkg/stacomir/man/choicemult-PasDeTemps-method.Rd
pkg/stacomir/man/fn_EcritBilanMensuel.Rd
Log:
Deleted: . Rinstignore
===================================================================
Added: pkg/stacomir/.Rinstignore
===================================================================
--- pkg/stacomir/.Rinstignore (rev 0)
+++ pkg/stacomir/.Rinstignore 2016-09-10 12:52:26 UTC (rev 205)
@@ -0,0 +1,5 @@
+inst/config/generate_ROxygen2.R
+inst/config/libraries.r
+inst/stacomi_manual_launch.r
+inst/test_vignette.R
+inst/testthat.R
\ No newline at end of file
Modified: pkg/stacomir/NAMESPACE
===================================================================
--- pkg/stacomir/NAMESPACE 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/NAMESPACE 2016-09-10 12:52:26 UTC (rev 205)
@@ -37,6 +37,7 @@
exportClasses(Bilan_poids_moyen)
exportClasses(Bilan_stades_pigm)
exportClasses(Bilan_taille)
+exportMethods(DateFin)
exportMethods(calcule)
exportMethods(charge)
exportMethods(charge_avec_filtre)
Modified: pkg/stacomir/R/BilanFonctionnementDF.r
===================================================================
--- pkg/stacomir/R/BilanFonctionnementDF.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/BilanFonctionnementDF.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -113,19 +113,19 @@
#' The choice_c method fills in the data slot for RefDC, and then
#' uses the choice_c methods of these object to "select" the data.
#' @param object An object of class \link{RefDC-class}
+#' @param df The df to set
#' @param horodatedebut A POSIXt or Date or character to fix the date of beginning of the Bilan
#' @param horodatefin A POSIXt or Date or character to fix the last date of the Bilan
#' @return An object of class \link{RefDC-class} with slots filled
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
-setMethod("choice_c",signature=signature("BilanFonctionnementDF"),definition=function(object,horodatedebut,horodatefin,...){
-
- # only taxa present in the bilanMigration are used
- fonctionnementDF<-new("BilanFonctionnementDF")
+setMethod("choice_c",signature=signature("BilanFonctionnementDF"),definition=function(object,df,horodatedebut,horodatefin,...){
+ # fonctionnementDF<-BfDF
+ fonctionnementDF<-object
assign("fonctionnementDF",fonctionnementDF,envir=envir_stacomi)
funout(get("msg",envir=envir_stacomi)$interface_BilanFonctionnementDC.1)
fonctionnementDF at df<-charge(fonctionnementDF at df)
- fonctionnementDF at df<-choice_c(fonctionnementDF at df)
+ fonctionnementDF at df<-choice_c(fonctionnementDF at df,df)
# assigns the parameter (horodatedebut) of the method to the object using choice_c method for RefDF
fonctionnementDF at horodatedebut<-choice_c(fonctionnementDF at horodatedebut,
nomassign="fonctionnementDF_date_debut",
Modified: pkg/stacomir/R/BilanMigration.r
===================================================================
--- pkg/stacomir/R/BilanMigration.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/BilanMigration.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -255,6 +255,28 @@
}
})
+#' Method to print the command line of the object
+#' @param x An object of class BilanMigrationMult
+#' @param ... Additional parameters passed to print
+#' @return NULL
+#' @author cedric.briand
+#' @export
+setMethod("print",signature=signature("BilanMigration"),definition=function(x,...){
+ sortie1<-"bilanMigration=new(bilanMigration)\n"
+ sortie2<-stringr::str_c("bilanMigration=choice_c(bilanMigration,",
+ "dc=c(",stringr::str_c(x at dc@dc_selectionne,collapse=","),"),",
+ "taxons=c(",stringr::str_c(shQuote(x at taxons@data$tax_nom_latin),collapse=","),"),",
+ "stades=c(",stringr::str_c(shQuote(x at stades@data$std_code),collapse=","),"),",
+ "datedebut=",shQuote(strftime(x at pasDeTemps@dateDebut,format="%d/%m/%Y")),
+ ",datefin=",shQuote(strftime(DateFin(x at pasDeTemps),format="%d/%m/%Y")),")")
+ # removing backslashes
+ funout(stringr::str_c(sortie1,sortie2),...)
+ return(invisible(NULL))
+ })
+
+
+
+
#' Plots of various type for BilanMigration, and performs writing to the database of daily values.
#'
#' \itemize{
@@ -353,7 +375,7 @@
} # end is.null(data)
#§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
- # step plot
+ # step plot
#§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
} else if (plot.type=="step"){
taxon= as.character(bilanMigration at taxons@data$tax_nom_latin)
@@ -393,7 +415,7 @@
"10"="#F0522D",
"11"="#912E0F",
"12"="#33004B"
- ))
+ ))
print(p)
} else {
funout(get("msg",envir_stacomi)$BilanMigration.8)
Modified: pkg/stacomir/R/BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMult.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/BilanMigrationMult.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -675,7 +675,6 @@
#' @param ... Additional parameters passed to print
#' @return NULL
#' @author cedric.briand
-#' @docType methods
#' @export
setMethod("print",signature=signature("BilanMigrationMult"),definition=function(x,...){
sortie1<-"bilanMigrationMult=new(bilanMigrationMult)\n"
Modified: pkg/stacomir/R/PasdeTemps.r
===================================================================
--- pkg/stacomir/R/PasdeTemps.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/PasdeTemps.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -38,10 +38,7 @@
rm(UNE_SECONDE,UNE_MINUTE,DIX_MINUTES,QUINZE_MINUTES,TRENTE_MINUTES,UNE_HEURE,DOUZE_HEURES,
UN_JOUR,UNE_SEMAINE,DEUX_SEMAINES,UN_MOIS,TROIS_MOIS,SIX_MOIS,UN_AN,LabelPasDeTemps)
-################################################################
-# Declarations de classe
-################################################################
-#fonction pour valider les objects de classe Pas deTemps
+
validite_PasDeTemps=function(object)
{
retValue=NULL
@@ -118,16 +115,7 @@
stepDuration=as.character("1 jour"),
nbStep=as.numeric(1),
noPasCourant=as.integer(0) ))
-#pasDeTempsChar=new("PasDeTempsChar")
-# pasDeTempsChar at stepDuration= "1 jour"
-# pasDeTempsChar at nbStep=as.integer(10)
-
-################################################################
-# Conversion de classe
-################################################################
-
-#Conversion depuis la classe charactere la classe numerique
setAs("PasDeTempsChar","PasDeTemps", # from to
function(from,to){
index=LesPasDeTemps[,"LabelPasDeTemps"]%in%from at stepDuration
@@ -138,15 +126,23 @@
noPasCourant=from at noPasCourant)})
# pasDeTemps=as(pasDeTempsChar,"PasDeTemps")
-################################################################
-# methodes standard
-################################################################
-# retourne le pas courant
+#' Generic method to get current time step
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("getnoPasCourant",def=function(object,...) standardGeneric("getnoPasCourant"))
+#' Gets the current time step of an object of class \link{PasDeTemps-class}
+#' @param object An object of class \link{PasDeTemps-class}
+#' @return the current time step of the object
setMethod("getnoPasCourant",signature=signature("PasDeTemps"),definition=function(object) object at noPasCourant)
-# retourne la date de fin
+#' Generic method for getting the final date
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("DateFin",def=function(object,...) standardGeneric("DateFin"))
+#' Gets the final horodate for an object of class \link{PasDeTemps-class}
+#' @param object An object of class \link{PasDeTemps-class}
+#' @return DateFin, The final date corresponding to nbStep*time duration + initial date
+#' @export
setMethod("DateFin",signature=signature("PasDeTemps"),definition=function(object){
DateFin=object at dateDebut+ object at stepDuration*(object at nbStep)
# pour les pb de changement d'heure
@@ -154,11 +150,13 @@
return(DateFin)
})
-#getnoPasCourant(EssaiPasdeTemps)
-
-
-#Retourne la date de debut correspondant au no de pas courant
+#' Generic method for getting the beginning date for current time step
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("currentDateDebut",def=function(object,...) standardGeneric("currentDateDebut"))
+#' Gets the starting date of a time step for an object of class \link{PasDeTemps-class}
+#' @param object An object of class \link{PasDeTemps-class}
+#' @return CurrentDateDebut, The starting date for the current timestep
setMethod("currentDateDebut",signature=signature("PasDeTemps"),definition=function(object){
CurrentDateDebut=object at dateDebut+ object at stepDuration*object at noPasCourant
# bug cht heure
@@ -168,22 +166,28 @@
return(CurrentDateDebut)
})
-# pasDeTemps at noPasCourant=as.integer(2)
-# currentDateDebut(pasDeTemps)
-
-# Retourne la date de fin correspondant au no de pas courant
+#' Generic method for getting the ending date for current time step
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("currentDateFin",def=function(object,...) standardGeneric("currentDateFin"))
+#' Gets the ending date of a time step for an object of class \link{PasDeTemps-class}
+#' @param object An object of class \link{PasDeTemps-class}
+#' @return CurrentDateFin, The ending date for the current timestep
setMethod("currentDateFin",signature=signature("PasDeTemps"),definition=function(object){
CurrentDateFin=object at dateDebut+ object at stepDuration*(object at noPasCourant+as.integer(1))
- # bug cht heure
if (object at stepDuration==86400) {
CurrentDateFin=Hmisc::round.POSIXt(CurrentDateFin,"days")
}
return(CurrentDateFin)
})
-#Avance au pas de temps suivant et retourne lengthno du nouveau pas de temps
+#' Generic method next
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("suivant",def=function(object,...) standardGeneric("suivant"))
+#' Gets the next time step
+#' @param object An object of class \link{PasDeTemps-class}
+#' @return An object of class \link{PasDeTemps-class} with current time step set
setMethod("suivant",signature=signature("PasDeTemps"),definition=function(object){
object at noPasCourant =object at noPasCourant+as.integer(1)
if (currentDateFin(object)>DateFin(object)) {
@@ -191,37 +195,70 @@
}
return (object)
})
-# retourne le libelle complet comme champ charactere
+
+#' Generic method the get starting date
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("getdateDebut",def=function(object,...) standardGeneric("getdateDebut"))
+#' Returns the starting date as character
+#' @param object An object of class \link{PasDeTemps-class}
+#' @param ... Additional parameters passed to the method
setMethod("getdateDebut",signature=signature("PasDeTemps"),definition=function(object){
return ( strftime(as.POSIXlt(object at dateDebut),format="%Y-%m-%d %H:%M:%S") )
})
-#Fixe la date de debut e partir d'un champ charactere de type "%Y-%m-%d %H:%M:%S" ou "%Y-%m-%d" (classe pas de temps journalier)
+
+#' Generic method to set the starting date
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("setdateDebut",def=function(object,...) standardGeneric("setdateDebut"))
+#' Sets starting date from a character
+#'
+#'
+#' @param object An object of class \link{PasDeTemps-class}
+#' @param string Character string of type"\%Y-\%m-\%d \%H:\%M:\%S" or "\%Y-\%m-\%d".
+#' this allows to use either horodate or date
+#' @return An object of class \link{PasDeTemps-class}
setMethod("setdateDebut",signature=signature("PasDeTemps"),definition=function(object,string){
object at dateDebut=if (!is.na(strptime(string,format="%Y-%m-%d %H:%M:%S"))) strptime(string,format="%Y-%m-%d %H:%M:%S") else
strptime(string,format="%Y-%m-%d")
return(object)
})
-# object=setdateDebut(object,"2008-05-01 00:00:00")
-# getdateDebut(object)
+#' Generic method to get the string value of time step
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("getLibellesPas",def=function(object,...) standardGeneric("getLibellesPas"))
+
+
+
+#' Gets the string value of time step
+#'
+#' @param object An object of class \link{PasDeTemps-class}
+#' @return A string corresponding to the value of current time step
setMethod("getLibellesPas",signature=signature("PasDeTemps"),definition=function(object){
ret=paste(LesPasDeTemps$LabelPasDeTemps)
return (ret )
})
+
+#' Generic method to get the years
+#' @param object An object
+#' @param ... Additional parameters passed to the method
setGeneric("getAnnees",def=function(object,...) standardGeneric("getAnnees"))
+
+#' Gets the year or a vector of years corresponding to the timestep ("PasDeTemps") object
+#' @param object An object of class \link{PasDeTemps-class}
setMethod("getAnnees",signature=signature("PasDeTemps"),definition=function(object){
dateFin=DateFin(object)
dateDebut=object at dateDebut
seq=seq.POSIXt(from=dateDebut,to=dateFin,by="day")
- seq=seq[-length(seq)]# dans le bilan Migration la derniere valeur n'est pas prise en compte
+ seq=seq[-length(seq)]
annees=unique(strftime(seq,"%Y"))
return (as.numeric(annees))
})
-# pour test #object=new("PasDeTemps")
+
+#' Method to select timesteps from the graphical interface
+#' @param object An object of class \link{PasDeTemps-class}
setMethod("choice",signature=signature("PasDeTemps"),definition=function(object) {
if (length(LesPasDeTemps$LabelPasDeTemps) > 0){
hwinpa=function(h,...){
@@ -230,18 +267,7 @@
object at nbStep<-nbStep
object at stepDuration<-as.numeric(LesPasDeTemps$ValeurPasDeTemps[LesPasDeTemps$LabelPasDeTemps%in%pas])
object=setdateDebut(object,svalue(datedeb))
- #object at nbStep<<-nbStep
- #object at stepDuration<<-LesPasDeTemps$ValeurPasDeTemps[LesPasDeTemps$LabelPasDeTemps%in%pas]
- assign("pasDeTemps",object,envir_stacomi)
- #funout("Les pas de temps ont ete charges\n")
- #print(object)
- # pour l'instant pour une raison inexpliquee, je n'arrive pas e traduire
- # object at nbStep dans l'environnement principal alors que object at stepDuration
- # est remplace dans object => ??????? je ne comprens pas....
- # Je le remplace par un assign du meme object mais ce n'est pas propre car cela
- # suppose que je ne peux avoir que lepas e passer e cette fonction
-
- #dispose(winpa)
+ assign("pasDeTemps",object,envir_stacomi)
}
hchoicepas=function(h,...){
pas=svalue(choicepas)
@@ -249,16 +275,10 @@
object at stepDuration<-as.numeric(LesPasDeTemps$ValeurPasDeTemps[LesPasDeTemps$LabelPasDeTemps%in%pas])
object at nbStep<-nbStep
object=setdateDebut(object,svalue(datedeb))
- #print(object at dateDebut)
-
- #assign("date",svalue(datedeb),envir = .GlobalEnv)
add(datedefin,strftime(as.POSIXlt(DateFin(object)),format="%Y-%m-%d %H:%M:%S"),
font.attr=c(foreground.colors="red") )
hwinpa(h)
}
- hchoicedatedebut=function(h,...){
- # TODO a developper
- }
winpa=gframe(get("msg",envir=envir_stacomi)$PasdeTemps.1,container=group,horizontal=FALSE)
pg<-ggroup(horizontal=FALSE,container=winpa)
glabel("Date de debut",container=pg)
@@ -282,8 +302,9 @@
})
-#' choice method for PasdeTemps
-#' this method differs from choice as it is called within a notebook,
+#' Graphical interface for multiple choice method for PasdeTemps (used in BilanMigrationMult)
+#' @param object An object of class \link{PasDeTemps-class}
+#' @note this method differs from choice as it is called within a notebook,
#' it does not allow for multiple choice to be made
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
@@ -339,7 +360,5 @@
} else funout(get("msg",envir=envir_stacomi)$PasdeTemps.3, arret=TRUE)
})
-# showClass("PasDeTemps")
-# validObject( pasDeTemps)
-# showMethods("suivant")
+
Modified: pkg/stacomir/R/RefDF.r
===================================================================
--- pkg/stacomir/R/RefDF.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/RefDF.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -149,13 +149,12 @@
} else if (class(df)=="character"){
df=as.integer(as.numeric(df))
}
- if (any(is.na(df))) stop ("NA values df")
-
-
+ if (any(is.na(df))) stop ("NA values df")
object at df_selectionne<-df
+ object at ouvrage= object at data$dif_ouv_identifiant[object at data$df%in%object at df_selectionne]
validObject(object)
# the method validObject verifies that the df is in the data slot of RefDF
- assign("refDF",object,envir=envir_stacomi)
+ assign("refDF",object,envir=envir_stacomi)
return(object)
})
\ No newline at end of file
Modified: pkg/stacomir/R/RefHorodate.r
===================================================================
--- pkg/stacomir/R/RefHorodate.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/RefHorodate.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -50,7 +50,6 @@
#' @param string A string representing an horodate in the format "\%Y-\%m-\%d \%H:\%M:\%S"
#' @return An Object of class "RefHorodate"
#' @author cedric.briand
-#' @docType methods
setMethod("setRefHorodate",signature=signature("RefHorodate"),definition=function(object,string){
object at horodate=strptime(string,format="%Y-%m-%d %H:%M:%S")
return(object)
Modified: pkg/stacomir/R/RefPoidsMoyenPeche.r
===================================================================
--- pkg/stacomir/R/RefPoidsMoyenPeche.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/RefPoidsMoyenPeche.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -43,7 +43,6 @@
#' @return An object of class \code{\linkS4class{RefPoidsMoyenPeche}}
#'
#' @author cedric.briand
-#' @docType methods
#' @export
setMethod("charge",signature=signature("RefPoidsMoyenPeche"),definition=function(object){
baseODBCmortciv<-get("baseODBCmortciv",envir=envir_stacomi)
Modified: pkg/stacomir/R/data.r
===================================================================
--- pkg/stacomir/R/data.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/data.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -76,4 +76,10 @@
#' \item{time.sequence}{A time sequence generated for the bilan, used internally}
#' }
#' @keywords data
-"bM_Arzal"
\ No newline at end of file
+"bM_Arzal"
+
+
+#' dataframe containing the default connection arguments
+#' the program will use a file installed in c:/program files/stacomi but
+#' if not found will switch to the default
+"calcmig"
Modified: pkg/stacomir/R/fn_EcritBilanJournalier.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanJournalier.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/fn_EcritBilanJournalier.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -99,7 +99,7 @@
DC=as.numeric(bilanMigration at dc@dc_selectionne)
tableau<-bilanMigration at calcdata[[stringr::str_c("dc_",DC)]][["data"]]
resum=funstat(tableau=tableau,time.sequence=tableau$debut_pas,taxon,stade,DC,silent=silent )
- fn_EcritBilanMensuel(bilanMigration,resum)
+ fn_EcritBilanMensuel(bilanMigration,resum,silent=silent)
}#end function hconfirm
if (nrow(bil at data)>0)
@@ -152,6 +152,6 @@
DC=as.numeric(bilanMigration at dc@dc_selectionne)
tableau<-bilanMigration at calcdata[[stringr::str_c("dc_",DC)]][["data"]]
resum=funstat(tableau=tableau,time.sequence=tableau$debut_pas,taxon,stade,DC,silent=silent)
- fn_EcritBilanMensuel(bilanMigration,resum)
+ fn_EcritBilanMensuel(bilanMigration,resum,silent=silent)
} # end else
} # end function
Modified: pkg/stacomir/R/fn_EcritBilanMensuel.r
===================================================================
--- pkg/stacomir/R/fn_EcritBilanMensuel.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/fn_EcritBilanMensuel.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -6,8 +6,9 @@
#'
#' @param bilanMigration an object of class \code{\linkS4class{BilanMigration}}
#' @param resum data frame with summary per month
+#' @param silent Suppresses messages
#' @export
-fn_EcritBilanMensuel<-function(bilanMigration,resum){
+fn_EcritBilanMensuel<-function(bilanMigration,resum,silent){
# voir essai_table_bilanmensuel.sql pour le format du tableau
# below not the most elegant way to do it but efficient
@@ -36,6 +37,6 @@
invisible(requete<-stacomirtools::connect(requete))
} # end for
odbcClose(requete at connection)
-funout(paste(get("msg",envir=envir_stacomi)$fn_EcritBilanMensuel.1,"\n"))
+if (!silent) funout(paste(get("msg",envir=envir_stacomi)$fn_EcritBilanMensuel.1,"\n"))
} # end function
Modified: pkg/stacomir/R/fungraph.r
===================================================================
--- pkg/stacomir/R/fungraph.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/fungraph.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -22,7 +22,6 @@
#browser()
#cat("fungraph")
if (is.null(dc)) dc=bilanMigration at dc@dc_selectionne[1]
- if (!identical(unique(tableau$type_de_quantite[!is.na(tableau$type_de_quantite)]),"effectif")) funout(get("msg",envir=envir_stacomi)$fungraph.1)
annee=unique(strftime(as.POSIXlt(time.sequence),"%Y"))
mois= months(time.sequence)
jour= strftime(as.POSIXlt(time.sequence),"%j")
@@ -356,10 +355,10 @@
tableau$mois=factor(months(tableau$debut_pas,abbreviate=TRUE),
levels=unique(months(tableau$debut_pas,abbreviate=TRUE)))
tableaum<-reshape2::melt(data=tableau[,c("MESURE","CALCULE","EXPERT","PONCTUEL","mois")],
- id.vars=c("mois"),
- measure.vars=c("MESURE","CALCULE","EXPERT","PONCTUEL"),
- variable.name="type",
- value.name="number")
+ id.vars=c("mois"),
+ measure.vars=c("MESURE","CALCULE","EXPERT","PONCTUEL"),
+ variable.name="type",
+ value.name="number")
levels(tableaum$type)<-get("msg",envir=envir_stacomi)$fungraph.5
superpose.polygon<-lattice::trellis.par.get("plot.polygon")
superpose.polygon$col= c("black","deepskyblue","chartreuse2","indianred")
@@ -395,7 +394,7 @@
points=FALSE,
space="right",
cex=0.8),
- origin=0)
+ origin=0)
print(bar,position = c(0, 0, 1, .25),newpage = FALSE)
Modified: pkg/stacomir/R/utilitaires.r
===================================================================
--- pkg/stacomir/R/utilitaires.r 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/R/utilitaires.r 2016-09-10 12:52:26 UTC (rev 205)
@@ -126,30 +126,26 @@
# use of stringr package
# by default the csv file is in C:/Program Files/stacomi/ and we don't want to change that
# note this will only be tested once the program is packages otherwise the path is inst/config/calcmig.csv
- filecsvR=file.path(.libPaths(),"stacomiR","config","calcmig.csv")
+
+
if (database_expected) {
filecsv<-"C:/Program Files/stacomi/calcmig.csv"
+ test<-file.access(filecsv,0)==0
+ if (test) {
+ calcmig<-utils::read.csv(filecsv,header=TRUE,sep=";")
+ # then we test using the file from the package in the config folder
+ } else {
+ # the access to csv file failed despite database_expected=true
+ # if the file does not open, we switch to the file located within the package
+ cat("C:/program files/calcmig.csv does not exist, switching to defaut package file")
+ data("calcmig")
+ }
} else {
- filecsv<-filecsvR
+ # no access to the database is expected, we are using the file in the data directory of the package
+ data("calcmig")
+ test<-FALSE
}
-
-
- test<-file.access(filecsv,0)==0
- # if the file does not open, we will switch to the file located within the package
- if (test) {
- doc<-utils::read.csv(filecsv,header=TRUE,sep=";")
- # then we test using the file from the package in the config folder
- } else {
- test2<-file.access(filecsvR,0)==0
- if (test2) {
- doc<-utils::read.csv(filecsvR,header=TRUE,sep=";")
- } else {
- stop("internal error, no access to the csv configuration file")
- }
- }
-
-
- tableau_config = t(doc) # renvoit une liste
+ tableau_config = t(calcmig) # renvoit une liste
datawd=tableau_config["datawd",]
lang=tableau_config["lang",]
#pgwd=tableau_config["pgwd",]
Added: pkg/stacomir/data/calcmig.rda
===================================================================
(Binary files differ)
Property changes on: pkg/stacomir/data/calcmig.rda
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R
===================================================================
--- pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/examples/02_BilanMigration/bilanMigration_Arzal.R 2016-09-10 12:52:26 UTC (rev 205)
@@ -27,7 +27,7 @@
#bM_Arzal<-connect(bM_Arzal)
#str(bM_Arzal at data)
# calculations
-bM_Arzal<-calcule(bM_Arzal)
+bM_Arzal<-calcule(bM_Arzal,silent=TRUE)
#Individual plot for all DC (standard), taxon and stage where data present
#silent argument to stop all messages
# this will also write daily and monthly migration balance to the database,
Deleted: pkg/stacomir/inst/config/calcmig.csv
===================================================================
--- pkg/stacomir/inst/config/calcmig.csv 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/inst/config/calcmig.csv 2016-09-10 12:52:26 UTC (rev 205)
@@ -1,2 +0,0 @@
-lienODBC;uid;pwd;sqldf.uid;sqldf.pwd;sqldf.dbname;sqldf.host;sqldf.port;pgwd;datawd;lang
-bd_contmig_nat;iav;iav;test;test;test;localhost;5432;;~/stacomi/;French
Modified: pkg/stacomir/inst/config/generate_data.R
===================================================================
--- pkg/stacomir/inst/config/generate_data.R 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/inst/config/generate_data.R 2016-09-10 12:52:26 UTC (rev 205)
@@ -1,4 +1,27 @@
#################################
+# generates calcmig data
+# In data :
+#For sets of data, set up a package to use lazy-loading of data.
+#
+#For objects which are system data, for example lookup tables used in calculations
+#within the function, use a file ‘R/sysdata.rda’ in the package sources or create the
+#objects by R code at package installation time.
+#
+#
+#A sometimes important distinction is that the second approach places
+#objects in the namespace but the first does not. So if it is important
+#that the function sees mytable as an object from the package,
+#it is system data and the second approach should be used.
+
+##################################
+filecsv<-"C:/Program Files/stacomi/calcmig.csv"
+calcmig<-utils::read.csv(filecsv,header=TRUE,sep=";")
+setwd("F:/workspace/stacomir/pkg/stacomir")
+devtools::use_data(calcmig,internal=FALSE,overwrite=TRUE)
+
+
+
+#################################
# generates messages as generated by RefMesssage()
# the message are in the default langage (english)
# from iav three dc with eels
Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00stacomir.R 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R 2016-09-10 12:52:26 UTC (rev 205)
@@ -7,9 +7,11 @@
)
-test_that("Test existence of csv file within package",{
- filecsv<-file.path(.libPaths(),"stacomiR","config","calcmig.csv");
- expect_equivalent(file.access(filecsv,0),0)
+test_that("Test existence calcmig data within package",{
+ data("calcmig")
+ calcmig<-calcmig
+ expect_equal(length(calcmig),11)
+
}
)
Modified: pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/inst/tests/testthat/test-01BilanMigrationMult.R 2016-09-10 12:52:26 UTC (rev 205)
@@ -40,6 +40,7 @@
stades=c("AGG","AGJ","CIV"),
datedebut="2012-01-01",
datefin="31/12/2012"))
+ options(warn = 0)
})
test_that("Tests one instance with error (dc does not exist)",
@@ -54,6 +55,7 @@
stades=c("AGG","AGJ","CIV"),
datedebut="2012-01-01",
datefin="31/12/2012"))
+ options(warn = 0)
})
test_that("Test example 01_BilanMigrationMult",
Modified: pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/inst/tests/testthat/test-02BilanMigration.R 2016-09-10 12:52:26 UTC (rev 205)
@@ -1,5 +1,5 @@
context("BilanMigration")
-test_that("Test an instance of bilanMigration",{
+test_that("Test an instance of BilanMigration",{
require(stacomiR)
stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
# overriding user schema to point to iav
@@ -71,7 +71,24 @@
assign("sch","iav.",envir_stacomi)
# this chunk is not launched from examples but loads the bM_Arzal dataset if connection works
data("bM_Arzal")
- bM_Arzal<-calcule(bM_Arzal)
- fn_EcritBilanJournalier(bilanMigration=bM_Arzal,silent=FALSE)
+ bM_Arzal<-calcule(bM_Arzal,silent=TRUE)
+ fn_EcritBilanJournalier(bilanMigration=bM_Arzal,silent=TRUE)
rm("envir_stacomi",envir =.GlobalEnv)
+ })
+
+test_that("print method works",
+ {
+ stacomi(gr_interface=FALSE,
+ login_window=FALSE,
+ database_expected=TRUE)
+ # overriding user schema
+ baseODBC<-get("baseODBC",envir=envir_stacomi)
+ baseODBC[c(2,3)]<-rep("iav",2)
+ assign("baseODBC",baseODBC,envir_stacomi)
+ sch<-get("sch",envir=envir_stacomi) # "iav."
+ assign("sch","iav.",envir_stacomi)
+ # this chunk is not launched from examples but loads the bM_Arzal dataset if connection works
+ data("bM_Arzal")
+ print(bM_Arzal)
+ rm("envir_stacomi",envir =.GlobalEnv)
})
\ No newline at end of file
Modified: pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/inst/tests/testthat/test-03BilanFonctionnementDF.R 2016-09-10 12:52:26 UTC (rev 205)
@@ -1,7 +1,28 @@
-# TODO: Add comment
-#
-# Author: cedric.briand
-###############################################################################
+context("BilanFonctionnementDF")
+test_that("Test an instance of BilanFonctionnementDF",{
+ require(stacomiR)
+ stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=FALSE)
+ # overriding user schema to point to iav
+ baseODBC<-get("baseODBC",envir=envir_stacomi)
+ baseODBC[c(2,3)]<-rep("iav",2)
+ assign("baseODBC",baseODBC,envir_stacomi)
+ sch<-get("sch",envir=envir_stacomi) # "iav."
+ assign("sch","iav.",envir_stacomi)
+
+ BfDF<-new("BilanFonctionnementDF")
+ options(warn = 2)
+ BfDF<-choice_c(BfDF,
+ 2,
+ horodatedebut="2013-01-01",
+ horodatefin="2013-12-31")
+ options(warn = 0)
+ # there should be data in
+ expect_gt(nrow(BfDF at df@data),0,
+ label="There should be data loaded by the choice_c method in the data slot of
+the RefDF slot,nrow(BfDF at df@data)")
+ expect_s4_class(BfDF,
+ "BilanMigration")
+ rm("envir_stacomi",envir =.GlobalEnv)
+ })
-
Modified: pkg/stacomir/man/BilanMigration-class.Rd
===================================================================
--- pkg/stacomir/man/BilanMigration-class.Rd 2016-09-09 17:53:58 UTC (rev 204)
+++ pkg/stacomir/man/BilanMigration-class.Rd 2016-09-10 12:52:26 UTC (rev 205)
@@ -61,7 +61,7 @@
#bM_Arzal<-connect(bM_Arzal)
#str(bM_Arzal at data)
# calculations
-bM_Arzal<-calcule(bM_Arzal)
+bM_Arzal<-calcule(bM_Arzal,silent=TRUE)
#Individual plot for all DC (standard), taxon and stage where data present
#silent argument to stop all messages
# this will also write daily and monthly migration balance to the database,
Added: pkg/stacomir/man/DateFin-PasDeTemps-method.Rd
===================================================================
--- pkg/stacomir/man/DateFin-PasDeTemps-method.Rd (rev 0)
+++ pkg/stacomir/man/DateFin-PasDeTemps-method.Rd 2016-09-10 12:52:26 UTC (rev 205)
@@ -0,0 +1,19 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/PasdeTemps.r
+\docType{methods}
+\name{DateFin,PasDeTemps-method}
+\alias{DateFin,PasDeTemps-method}
+\title{Gets the final horodate for an object of class \link{PasDeTemps-class}}
+\usage{
+\S4method{DateFin}{PasDeTemps}(object)
+}
+\arguments{
+\item{object}{An object of class \link{PasDeTemps-class}}
+}
+\value{
+DateFin, The final date corresponding to nbStep*time duration + initial date
+}
+\description{
+Gets the final horodate for an object of class \link{PasDeTemps-class}
+}
+
Added: pkg/stacomir/man/DateFin.Rd
===================================================================
--- pkg/stacomir/man/DateFin.Rd (rev 0)
+++ pkg/stacomir/man/DateFin.Rd 2016-09-10 12:52:26 UTC (rev 205)
@@ -0,0 +1,17 @@
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/stacomir -r 205
More information about the Stacomir-commits
mailing list