[Stacomir-commits] r352 - in pkg/stacomir: . R inst/config inst/examples inst/tests/testthat man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Apr 10 20:28:50 CEST 2017
Author: briand
Date: 2017-04-10 20:28:50 +0200 (Mon, 10 Apr 2017)
New Revision: 352
Added:
pkg/stacomir/inst/tests/testthat/test-10BilanConditionEnv.R
pkg/stacomir/inst/tests/testthat/test-11BilanMigrationMultConditionEnv.R
pkg/stacomir/inst/tests/testthat/test-12BilanMigrationCar.R
Removed:
pkg/stacomir/R/interface_chooselang.r
pkg/stacomir/man/interface_chooselang.Rd
Modified:
pkg/stacomir/DESCRIPTION
pkg/stacomir/NAMESPACE
pkg/stacomir/R/BilanFonctionnementDF.r
pkg/stacomir/R/BilanMigration.r
pkg/stacomir/R/BilanMigrationCar.r
pkg/stacomir/R/BilanMigrationInterAnnuelle.r
pkg/stacomir/R/BilanMigrationMult.r
pkg/stacomir/R/BilanMigrationMultConditionEnv.r
pkg/stacomir/R/data.r
pkg/stacomir/R/interface_BilanMigrationMult.r
pkg/stacomir/R/messages.r
pkg/stacomir/R/stacomi.r
pkg/stacomir/inst/config/generate_Roxygen2.R
pkg/stacomir/inst/config/testthat.R
pkg/stacomir/inst/examples/bilanAgedemer_example.R
pkg/stacomir/inst/examples/bilanMigrationCar-example.R
pkg/stacomir/inst/tests/testthat/test-00stacomir.R
pkg/stacomir/man/BilanAgedemer-class.Rd
pkg/stacomir/man/calcmig.Rd
pkg/stacomir/man/plot-BilanMigrationCar-missing-method.Rd
pkg/stacomir/man/setasqualitative-BilanMigrationCar-method.Rd
pkg/stacomir/man/supprime-BilanAgedemer-method.Rd
Log:
Modified: pkg/stacomir/DESCRIPTION
===================================================================
--- pkg/stacomir/DESCRIPTION 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/DESCRIPTION 2017-04-10 18:28:50 UTC (rev 352)
@@ -1,6 +1,6 @@
Package: stacomiR
Version: 0.5.1
-Date: 2017-02-01
+Date: 2017-04-10
Title: Fish Migration Monitoring (stacomiR)
Authors at R: c(person("Cedric", "Briand", role = c("aut", "cre"), email = "cedric.briand00 at gmail.com"),
person("Marion", "Legrand", role = "aut", email="tableau-salt-loire at logrami.fr"),
@@ -8,7 +8,7 @@
Description: Graphical outputs and treatment for a database of fishway
monitoring. It is a part of the STACOMI open source project developed in France
by the ONEMA institute to centralize data obtained by fishway monitoring.
- Version 0.5.1 is available in French English and Spanish.
+ Version 0.5.1 is available in French English.
License: GPL (>= 2)
Collate:
'create_generic.r'
@@ -71,7 +71,6 @@
'interface_Bilan_carlot.r'
'interface_Bilan_taille.r'
'interface_bilan_poids_moyen.r'
- 'interface_chooselang.r'
'messages.r'
'setAs.r'
'stacomi.r'
Modified: pkg/stacomir/NAMESPACE
===================================================================
--- pkg/stacomir/NAMESPACE 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/NAMESPACE 2017-04-10 18:28:50 UTC (rev 352)
@@ -45,6 +45,7 @@
exportClasses(Bilan_carlot)
exportClasses(Bilan_poids_moyen)
exportMethods(DateFin)
+exportMethods(setasqualitative)
exportMethods(barplot)
exportMethods(calcule)
exportMethods(charge)
Modified: pkg/stacomir/R/BilanFonctionnementDF.r
===================================================================
--- pkg/stacomir/R/BilanFonctionnementDF.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/BilanFonctionnementDF.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -235,7 +235,7 @@
xlab(gettext("month",domain="R-stacomiR"))+
ggtitle(main)+
geom_bar(stat='identity')+
- scale_fill_manual(get("msg",envir_stacomi)$BilanFonctionnementDF.6[2],
+ scale_fill_manual(gettext("operation"),
values = c("#E41A1C","#E6AB02", "#9E0142","#1B9E77","#999999"))
t_periodefonctdispositif_per_mois=t_periodefonctdispositif_per_mois[order(t_periodefonctdispositif_per_mois$per_etat_fonctionnement),]
Modified: pkg/stacomir/R/BilanMigration.r
===================================================================
--- pkg/stacomir/R/BilanMigration.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/BilanMigration.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -592,8 +592,8 @@
data=data[data$Effectif_total!=0,]
jour_dans_lannee_non_nuls=data$debut_pas
col_a_retirer=match(c("No.pas","type_de_quantite","debut_pas","fin_pas"),colnames(data))
- col_a_retirer=col_a_retirer[!is.na(col_a_retirer)] # car dans le cas des civelles et poids
- # les colonnes ne sont pas les mêmes
+ col_a_retirer=col_a_retirer[!is.na(col_a_retirer)] # as in the case of glass eel and weight
+ # the columns are not the same
data=data[,-col_a_retirer]
# below again the taux_d_echappement not there if glass eel and weights
if (is.null(data$taux_d_echappement)) data$taux_d_echappement<-NA
Modified: pkg/stacomir/R/BilanMigrationCar.r
===================================================================
--- pkg/stacomir/R/BilanMigrationCar.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/BilanMigrationCar.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -130,7 +130,7 @@
#' Used by the graphical interface to collect and test objects in the environment envir_stacomi,
#' fills also the data slot by the connect method
#' @param object An object of class \link{BilanMigrationMult-class}
-#' @param silent Default FALSE, if TRUE the program should no display messages
+#' @param silent Default FALSE, if TRUE the program should not display messages
#' @return \link{BilanMigrationCar-class} with slots filled by user choice
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
setMethod("charge",signature=signature("BilanMigrationCar"),definition=function(object,silent=FALSE){
@@ -193,12 +193,13 @@
} else {
echantillons=""
}
-
-
- if (nrow(bmC at parquan@data)==0 & nrow(bmC at parqual@data)==0) {
+ # data can be selected but not in the database or the inverse
+ parquan<-intersect(bmC at parquan@par_selectionne,bmC at parquan@data$par_code)
+ parqual<-intersect(bmC at parqual@par_selectionne,bmC at parqual@data$par_code)
+ if (length(parquan)==0 & length(parqual)==0) {
stop("You need to choose at least one quantitative or qualitative attribute")
} else {
- if (nrow(bmC at parqual@data)!=0) {
+ if (length(parqual)!=0) {
#caracteristique qualitative
req=new("RequeteODBC")
req at baseODBC<-get("baseODBC", envir=envir_stacomi)
@@ -226,7 +227,7 @@
,sep="")
bmC at data[["parqual"]]<-connect(req)@query
}# end if (parqual)
- if (nrow(bmC at parquan@data)!=0) {
+ if (length(parquan)!=0) {
# Caracteristique quantitative
req=new("RequeteODBC")
req at baseODBC<-get("baseODBC", envir=envir_stacomi)
@@ -267,11 +268,13 @@
calcule(h$action)
}
#' Turns a quantitative parameter into qualitative
+#'
#' @param object An object of class \link{Refparquan-class}
#' @param par The code of a quantitative parameter
+#' @param silent Default FALSE, if TRUE the program should not display messages
#' @param ... Additional parms to the cut method \link[base]{cut}
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-#' @export
+#' @export
setMethod("setasqualitative",signature=signature("BilanMigrationCar"),definition=function(object,par,silent=FALSE,...) {
bmC<-object
# par <-'A124'
@@ -313,9 +316,18 @@
bmC<-object
qual<-bmC at data[["parqual"]]
quan<-bmC at data[["parquan"]]
- qual<-chnames(qual,"car_par_code","car_par_code_qual")
- quan<-chnames(quan,"car_par_code","car_par_code_quan")
+ if (is.null(qual)&is.null(quan)) stop("cannot perform calcule method, no data in either qualitative or quantitative parameters")
+ if (!is.null(qual)) qual<-chnames(qual,"car_par_code","car_par_code_qual")
+ if (!is.null(quan)) quan<-chnames(quan,"car_par_code","car_par_code_quan")
+ if (is.null(qual)) {
+ quaa<-quan
+ quaa$car_par_code_qual=NA
+ } else if (is.null(quan)) {
+ quaa<-qual
+ quaa$car_par_code_quan=NA
+ } else {
quaa<-merge(qual,quan,by=c("ope_dic_identifiant","lot_identifiant","ope_date_debut","ope_date_fin","lot_methode_obtention","lot_effectif","lot_tax_code","lot_std_code"),all.x=TRUE,all.y=TRUE)
+ }
quaa=funtraitementdate(data=quaa,nom_coldt="ope_date_debut")
quaa<-quaa[order(quaa$ope_dic_identifiant,quaa$lot_tax_code,quaa$lot_std_code,quaa$ope_date_debut),]
bmC at calcdata<-quaa
@@ -511,7 +523,7 @@
}
return(xt)} else
{
- #TODO tester et développer pour plusieurs années}
+ #TODO test and develop for several year}
}
})
Modified: pkg/stacomir/R/BilanMigrationInterAnnuelle.r
===================================================================
--- pkg/stacomir/R/BilanMigrationInterAnnuelle.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/BilanMigrationInterAnnuelle.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -565,7 +565,7 @@
dat$jour = as.POSIXct(strptime(strftime(dat$jour,'2000-%m-%d %H:%M:%S'),format='%Y-%m-%d %H:%M:%S'),tz="GMT")
dat$annee=as.factor(dat$annee)
dat=stacomirtools::killfactor(dat)
- titre=paste(get("msg",envir_stacomi)$BilanMigrationInterannuelle.4,
+ titre=paste(gettext("Migration for years "),
paste(min(dat$annee),max(dat$annee), collapse=":"),
", ",
bilanMigrationInterAnnuelle at dc@data$dis_commentaires[bilanMigrationInterAnnuelle at dc@data$dc==bilanMigrationInterAnnuelle at dc@dc_selectionne])
Modified: pkg/stacomir/R/BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMult.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/BilanMigrationMult.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -94,7 +94,6 @@
if (exists("pasDeTemps",envir_stacomi)){
bilanMigrationMult at pasDeTemps<-get("pasDeTemps",envir_stacomi)
} else {
- # todo addmsg
funout(gettext("Attention, no time step selected, compunting with default value\n",domain="R-stacomiR"),arret=FALSE)
warning("Attention, no time step selected, compunting with default value\n")
}
@@ -546,8 +545,8 @@
print(p)
assign("p",p,envir=envir_stacomi)
assign("grdata",grdata_without_hole,envir_stacomi)
- funout(gettext("The plot has been assigned to p in envir_stacomi,write p<-get('p',envir_stacomi) to retreive the object"))
- funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retreive the object"))
+ if (!silent) funout(gettext("The plot has been assigned to p in envir_stacomi,write p<-get('p',envir_stacomi) to retreive the object"))
+ if (!silent) funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retreive the object"))
}
#==========================type=3=============================
@@ -576,9 +575,9 @@
print(p)
assign("p",p,envir=envir_stacomi)
- funout(gettext("The plot has been assigned to p in envir_stacomi,write p<-get('p',envir_stacomi) to retreive the object"))
+ if (!silent) funout(gettext("The plot has been assigned to p in envir_stacomi,write p<-get('p',envir_stacomi) to retreive the object"))
assign("grdata",grdata,envir_stacomi)
- funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retreive the object"))
+ if (!silent) funout(gettext("The data for the plot have been assigned to envir_stacomi,write grdata<-get('grdata',envir_stacomi) to retreive the object"))
}
#==========================end / type=3=============================
Modified: pkg/stacomir/R/BilanMigrationMultConditionEnv.r
===================================================================
--- pkg/stacomir/R/BilanMigrationMultConditionEnv.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/BilanMigrationMultConditionEnv.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -161,9 +161,6 @@
stades= as.character(bmmCE at bilanMigrationMult@stades at data$std_libelle)
dc<-unique(grdata$DC)
stations<-bmmCE at bilanConditionEnv@stationMesure at data
- # pour avoir dans le graphique le dc_code des dc
- # ggplot passe les dc dans l'ordre dans lequel ils apparaissent dans le tableau
- # et unique fait ça aussi .... OUIIIII
dc_code<-bmmCE at bilanMigrationMult@dc at data$dc_code[
match(dc,bmmCE at bilanMigrationMult@dc at data$dc)]
# tableau conditions environnementales
@@ -236,8 +233,8 @@
######################
- # traitement des données pour grouper par dc (group_by dc)
- # les stades et taxons seront aggrégés avec warning
+ # treatment of data to group by dc
+ # if several taxa or stages are passed, they are aggregated with a warning
#################################
if (length(unique(taxons))>1) warning(gettextf("you have %s taxa in the bilan, those will be aggregated",length(unique(taxons))))
if (length(unique(stades))>1) warning(gettextf("you have %s stages in the bilan, those will be aggregated",length(unique(stades))))
Modified: pkg/stacomir/R/data.r
===================================================================
--- pkg/stacomir/R/data.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/data.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -199,7 +199,7 @@
#' @keywords data
"b_carlot"
-#' Daily glass eel and elver migration from 1984 to 2016 in the Sèvre Niortaise
+#' Daily glass eel and elver migration from 1984 to 2016 in the S \u0168 vre Niortaise
#'
#' The first eel trapping ladder in France was built by Antoine Legault and the team from Rennes
#' in the Sevre Niortaise, Marais Poitevin. Also refurbished several times since 1984 it has been
Modified: pkg/stacomir/R/interface_BilanMigrationMult.r
===================================================================
--- pkg/stacomir/R/interface_BilanMigrationMult.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/interface_BilanMigrationMult.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -38,8 +38,6 @@
ggroupboutonsbas = gWidgets::ggroup(horizontal=FALSE)
assign("ggroupboutonsbas",ggroupboutonsbas,envir=.GlobalEnv)
gWidgets::add(ggroupboutons,ggroupboutonsbas)
- # todo addmsg
- # getStockIcons()
toolbarlist = list(
Calc=gWidgets::gaction(handler=hbilanMigrationMultcalc, icon="new",
label="calcul",
Deleted: pkg/stacomir/R/interface_chooselang.r
===================================================================
--- pkg/stacomir/R/interface_chooselang.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/interface_chooselang.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -1,30 +0,0 @@
-# Nom fichier : interface_chooselang.R (interface)
-
-#' An interface that calls the object to build the user interface
-#' @note always has to be called within a group constructed and deleted using quitte()
-#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-interface_chooselang = function()
-{
- quitte() # vidange de l'interface
- group <- gWidgets::ggroup(horizontal=FALSE) # doit toujours s'appeller group
- assign("group",group,envir = .GlobalEnv)
- add(ggroupboutons,group)
- listlang<-new("RefListe")
- listlang at listechoice=c("french","english","spanish")
- listlang at label=gettext("choose language")
- choice(listlang)
- hassingnlang=function(h,...){
- lang<-get("refliste",envir_stacomi)@listechoice
- messages(lang)
- close(win)
- interface_graphique()
- }
- ggroupboutonsbas = gWidgets::ggroup(horizontal=FALSE)
-assign("ggroupboutonsbas",ggroupboutonsbas,envir=.GlobalEnv)
- gWidgets::add(ggroupboutons,ggroupboutonsbas)
- toolbarlist = list(
- annuler=gWidgets::gaction(handler= hassingnlang,icon = "close",label="quitter")
- )
- gWidgets::add(ggroupboutonsbas, gtoolbar(toolbarlist))
- gWidgets::addSpring(group)
-}
Modified: pkg/stacomir/R/messages.r
===================================================================
--- pkg/stacomir/R/messages.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/messages.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -22,15 +22,15 @@
#' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
#' @export
# exported for test_that
-messages=function(lang="French"){
+messages=function(){
msg=list()
# RequeteODBC
- msg$RequeteODBC.1<-"Error ODBC =>Define a vector baseODBC with the name of the ODBC link, user and password \n"
- msg$RequeteODBC.2<-"Connection trial :"
- msg$RequeteODBC.3<-"Connection failure :"
- msg$RequeteODBC.4<-"Connection successful \n"
- msg$RequeteODBC.5<-"Trying query \n"
- msg$RequeteODBC.6<-"Query succeded \n"
+ msg$RequeteODBC.1<-gettext("Error ODBC =>Define a vector baseODBC with the name of the ODBC link, user and password")
+ msg$RequeteODBC.2<-gettext("Connection trial :")
+ msg$RequeteODBC.3<-gettext("Connection failure :")
+ msg$RequeteODBC.4<-gettext("Connection successful")
+ msg$RequeteODBC.5<-gettext("Trying query")
+ msg$RequeteODBC.6<-gettext("Query succeded")
# RequeteODBCwhere
# RequeteODBCwheredate
Modified: pkg/stacomir/R/stacomi.r
===================================================================
--- pkg/stacomir/R/stacomi.r 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/R/stacomi.r 2017-04-10 18:28:50 UTC (rev 352)
@@ -229,20 +229,12 @@
}
}
}
-hhelp=function(h,...){
- funout(gettext("For help, contact Cedric Briand - 0033 29 99 08 844 - cedric.briand at eptb-vilaine.fr or stacomi at googlegroups.com.\n",domain="R-stacomiR"),wash=TRUE)
-}
-hlang=function(h,...){
- eval(interface_chooselang(),envir = .GlobalEnv)
-}
-hX11=function(h,...){
- dev.new()
-}
+
#' Function that loads the loginwindow, tests connection, and then destroys the
#' window
#'
@@ -344,10 +336,9 @@
mylinks=chargecsv(database_expected)
baseODBC=mylinks[["baseODBC"]]
datawd=mylinks[["datawd"]]
- lang=mylinks[["lang"]]
+ lang=mylinks[["lang"]] # deprecated this option is set at the higher level in R
sqldf.options=mylinks[["sqldf.options"]]
# values assigned in the envir_stacomi
- assign("lang",lang,envir=envir_stacomi)
assign("datawd",datawd,envir=envir_stacomi)
assign("sqldf.options",sqldf.options,envir=envir_stacomi)
@@ -464,12 +455,6 @@
menubarlist[[gettext("Summary",domain="R-stacomiR")]][[gettext("Treatment size - age salmonids",domain="R-stacomiR")]]$handler=hbilanagedemer
menubarlist[[gettext("Summary",domain="R-stacomiR")]][[gettext("Treatment size - age salmonids",domain="R-stacomiR")]]$icon="gWidgetsRGtk2-hist"
- menubarlist[[gettext("Help",domain="R-stacomiR")]]$About$handler = hX11
- menubarlist[[gettext("Help",domain="R-stacomiR")]]$About$icon="newplot"
- menubarlist[[gettext("Help",domain="R-stacomiR")]]$About$handler = hhelp
- menubarlist[[gettext("Help",domain="R-stacomiR")]]$About$icon="dialog-info"
- menubarlist[[gettext("Help",domain="R-stacomiR")]]$lang$handler = hlang
- menubarlist[[gettext("Help",domain="R-stacomiR")]]$lang$icon="dialog-info"
gWidgets::add(win, gmenu(menubarlist))
ggrouptotal<- gWidgets::ggroup(horizontal=FALSE)
# gsortie is above the window
Modified: pkg/stacomir/inst/config/generate_Roxygen2.R
===================================================================
--- pkg/stacomir/inst/config/generate_Roxygen2.R 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/inst/config/generate_Roxygen2.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -23,8 +23,7 @@
# devtools::install_version(package = 'roxygen2',version = '5.0.1', repos = c(CRAN = "https://cran.rstudio.com"))
##use either :
require(devtools)
- envir_stacomi <- new.env(parent = emptyenv())
- data("calcmig")
+# uncomment lines in stacomi to run the program (calcmig and envir_stacomi necessary)
document("F:/workspace/stacomir/pkg/stacomir")
## or :
##vignette("roxygen2")
Modified: pkg/stacomir/inst/config/testthat.R
===================================================================
--- pkg/stacomir/inst/config/testthat.R 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/inst/config/testthat.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -21,4 +21,5 @@
test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-05Bilan_carlot.R")
test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-06Bilan_MigrationInterAnnuelle.R")
test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-07BilanAgedemer.R")
+test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-08BilanArgentee.R")
test_file("F:/workspace/stacomir/pkg/stacomir/inst/tests/testthat/test-08BilanArgentee.R")
\ No newline at end of file
Modified: pkg/stacomir/inst/examples/bilanAgedemer_example.R
===================================================================
--- pkg/stacomir/inst/examples/bilanAgedemer_example.R 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/inst/examples/bilanAgedemer_example.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -38,4 +38,6 @@
# print a summary statistic, and save the output in a list for later use
stats<-summary(bilan_adm)
+\dontrun{
write_database(bilan_adm)
+}
Modified: pkg/stacomir/inst/examples/bilanMigrationCar-example.R
===================================================================
--- pkg/stacomir/inst/examples/bilanMigrationCar-example.R 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/inst/examples/bilanMigrationCar-example.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -36,3 +36,29 @@
plot(bmC,plot.type="crossed")
plot(bmC,plot.type="crossed",color_parm=c("age 1"="#379ec6","age 2"="#173957","age 3"="#b09953"))
xt<-xtable(bmC)
+# use method print.xtable to get the output
+\dontrun{
+# An example with several years
+bmC<-new("BilanMigrationCar")
+baseODBC<-get("baseODBC",envir=envir_stacomi)
+baseODBC[c(2,3)]<-rep("logrami",2)
+assign("baseODBC",baseODBC,envir_stacomi)
+sch<-get("sch",envir=envir_stacomi)
+assign("sch","logrami.",envir_stacomi)
+# here parqual is not in the list
+# so this is equivalent to parqual=NULL
+bmC<-choice_c(bmC,
+ dc=c(107,108,101),
+ taxons=c("Salmo salar"),
+ stades=c('5','11','BEC','BER','IND'),
+ parquan=c('A124','C001','1786','1785'),
+ horodatedebut="2009-01-01",
+ horodatefin="2012-12-31",
+ silent=FALSE)
+# bmC<-charge(bmC) not necessary there
+bmC<-connect(bmC)
+# load the dataset generated by previous lines
+bmC<-setasqualitative(bmC,par='A124',breaks=c(0,1.5,2.5,10),label=c("age 1","age 2","age 3"))
+bmC<-calcule(bmC,silent=TRUE)
+}
+
Modified: pkg/stacomir/inst/tests/testthat/test-00stacomir.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-00stacomir.R 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/inst/tests/testthat/test-00stacomir.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -37,7 +37,7 @@
con at baseODBC=baseODBC
con<-connect(con)
expect_is(connect(con),'ConnectionODBC')
- expect_equal(con at etat,NULL)
+ expect_equal(con at etat,"Connection in progress")
odbcCloseAll()
rm("envir_stacomi",envir =.GlobalEnv)
})
Added: pkg/stacomir/inst/tests/testthat/test-10BilanConditionEnv.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-10BilanConditionEnv.R (rev 0)
+++ pkg/stacomir/inst/tests/testthat/test-10BilanConditionEnv.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -0,0 +1,7 @@
+# TODO: Add comment
+#
+# Author: cedric.briand
+###############################################################################
+
+
+
Added: pkg/stacomir/inst/tests/testthat/test-11BilanMigrationMultConditionEnv.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-11BilanMigrationMultConditionEnv.R (rev 0)
+++ pkg/stacomir/inst/tests/testthat/test-11BilanMigrationMultConditionEnv.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -0,0 +1,7 @@
+# TODO: Add comment
+#
+# Author: cedric.briand
+###############################################################################
+
+
+
Added: pkg/stacomir/inst/tests/testthat/test-12BilanMigrationCar.R
===================================================================
--- pkg/stacomir/inst/tests/testthat/test-12BilanMigrationCar.R (rev 0)
+++ pkg/stacomir/inst/tests/testthat/test-12BilanMigrationCar.R 2017-04-10 18:28:50 UTC (rev 352)
@@ -0,0 +1,100 @@
+context("BilanMigrationCar")
+
+
+test_that("test creating an instance of BilanMigrationCar and connect method (logrami required)",{
+ require(stacomiR)
+ stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=TRUE)
+ # overriding user schema to point to iav
+ assign("sch","logrami.",envir_stacomi)
+ bmC<-new("BilanMigrationCar")
+ baseODBC<-get("baseODBC",envir=envir_stacomi)
+ baseODBC[c(2,3)]<-rep("logrami",2)
+ assign("baseODBC",baseODBC,envir_stacomi)
+ sch<-get("sch",envir=envir_stacomi)
+ assign("sch","logrami.",envir_stacomi)
+# here parqual is not in the list
+# so this is equivalent to parqual=NULL
+ bmC<-choice_c(bmC,
+ dc=c(107,108,101),
+ taxons=c("Salmo salar"),
+ stades=c('5','11','BEC','BER','IND'),
+ parquan=c('A124','C001'),
+ parqual=NULL,
+ horodatedebut="2009-01-01",
+ horodatefin="2012-12-31",
+ silent=FALSE)
+# bmC<-charge(bmC) not necessary there
+ bmC<-connect(bmC)
+ expect_true(is.null(bmC at data$parqual),label="there should be no data in parqual when not qualitative parm are selected")
+ expect_true(nrow(bmC at data$parquan)>0,"There should be data in the parquan slot when quantitative parm are selected" )
+ rm("envir_stacomi",envir =.GlobalEnv)
+ })
+
+test_that("test setasqualitative method",{
+ require(stacomiR)
+ stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=TRUE)
+ # overriding user schema to point to iav
+ assign("sch","logrami.",envir_stacomi)
+ bmC<-new("BilanMigrationCar")
+ baseODBC<-get("baseODBC",envir=envir_stacomi)
+ baseODBC[c(2,3)]<-rep("logrami",2)
+ assign("baseODBC",baseODBC,envir_stacomi)
+ sch<-get("sch",envir=envir_stacomi)
+ assign("sch","logrami.",envir_stacomi)
+# here parqual is not in the list
+# so this is equivalent to parqual=NULL
+ bmC<-choice_c(bmC,
+ dc=c(107,108,101),
+ taxons=c("Salmo salar"),
+ stades=c('5','11','BEC','BER','IND'),
+ parquan=c('A124','C001'),
+ parqual=NULL,
+ horodatedebut="2009-01-01",
+ horodatefin="2012-12-31",
+ silent=FALSE)
+# bmC<-charge(bmC) not necessary there
+ bmC<-connect(bmC)
+# load the dataset generated by previous lines
+ bmC<-setasqualitative(bmC,par='A124',silent=FALSE,breaks=c(0,1.5,2.5,10),label=c("age 1","age 2","age 3"))
+ expect_true(bmC at parqual@par_selectionne=='A124', label="Test passing quant parm A124 to qualitative failed")
+ expect_false(bmC at parquan@par_selectionne=='A124', label="The parameter A124 should have been removed from quant parm")
+ expect_true('A124'%in%bmC at data$parqual$car_par_code)
+ expect_false('A124'%in%bmC at data$parquan$car_par_code)
+ rm("envir_stacomi",envir =.GlobalEnv)
+ })
+
+
+test_that("test calcule method",{
+ require(stacomiR)
+ stacomi(gr_interface=FALSE,login_window=FALSE,database_expected=TRUE)
+ # overriding user schema to point to iav
+ assign("sch","logrami.",envir_stacomi)
+ bmC<-new("BilanMigrationCar")
+ baseODBC<-get("baseODBC",envir=envir_stacomi)
+ baseODBC[c(2,3)]<-rep("logrami",2)
+ assign("baseODBC",baseODBC,envir_stacomi)
+ sch<-get("sch",envir=envir_stacomi)
+ assign("sch","logrami.",envir_stacomi)
+ bmC<-choice_c(bmC,
+ dc=c(107,108,101),
+ taxons=c("Salmo salar"),
+ stades=c('5','11','BEC','BER','IND'),
+ parquan=c('A124','C001'),
+ parqual=NULL,
+ horodatedebut="2012-01-01",
+ horodatefin="2012-12-31",
+ silent=FALSE)
+ bmC<-connect(bmC)
+ bmC<-calcule(bmC)
+ expect_true(nrow(bmC at calcdata)>0, label="Test that calcule method worked")
+ expect_true(all(is.na(bmC at calcdata$car_par_code_qual)), label="Test that calcule method does not return any qualitative result in absence of qualitative parm")
+
+ # now with a qualitative parm
+ bmC<-setasqualitative(bmC,par='A124',silent=FALSE,breaks=c(0,1.5,2.5,10),label=c("age 1","age 2","age 3"))
+ bmC<-calcule(bmC)
+ expect_true(any(!is.na(bmC at calcdata$car_par_code_qual))&any(!is.na(bmC at calcdata$car_par_code_quan)), label="The merge function works and returns both qualitative and quantitative parameters")
+
+ rm("envir_stacomi",envir =.GlobalEnv)
+ })
+
+
Modified: pkg/stacomir/man/BilanAgedemer-class.Rd
===================================================================
--- pkg/stacomir/man/BilanAgedemer-class.Rd 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/man/BilanAgedemer-class.Rd 2017-04-10 18:28:50 UTC (rev 352)
@@ -92,8 +92,10 @@
# print a summary statistic, and save the output in a list for later use
stats<-summary(bilan_adm)
+\dontrun{
write_database(bilan_adm)
}
+}
\seealso{
Other Bilan Objects: \code{\link{BilanAnnuels-class}},
\code{\link{BilanArgentee-class}},
Modified: pkg/stacomir/man/calcmig.Rd
===================================================================
--- pkg/stacomir/man/calcmig.Rd 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/man/calcmig.Rd 2017-04-10 18:28:50 UTC (rev 352)
@@ -6,7 +6,7 @@
\title{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}
-\format{An object of class \code{data.frame} with 1 rows and 11 columns.}
+\format{An object of class \code{data.frame} with 0 rows and 0 columns.}
\usage{
calcmig
}
Deleted: pkg/stacomir/man/interface_chooselang.Rd
===================================================================
--- pkg/stacomir/man/interface_chooselang.Rd 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/man/interface_chooselang.Rd 2017-04-10 18:28:50 UTC (rev 352)
@@ -1,17 +0,0 @@
-% Generated by roxygen2: do not edit by hand
-% Please edit documentation in R/interface_chooselang.r
-\name{interface_chooselang}
-\alias{interface_chooselang}
-\title{An interface that calls the object to build the user interface}
-\usage{
-interface_chooselang()
-}
-\description{
-An interface that calls the object to build the user interface
-}
-\note{
-always has to be called within a group constructed and deleted using quitte()
-}
-\author{
-Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
-}
Modified: pkg/stacomir/man/plot-BilanMigrationCar-missing-method.Rd
===================================================================
--- pkg/stacomir/man/plot-BilanMigrationCar-missing-method.Rd 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/man/plot-BilanMigrationCar-missing-method.Rd 2017-04-10 18:28:50 UTC (rev 352)
@@ -6,12 +6,12 @@
\title{plot method for BilanMigrationCar}
\usage{
\S4method{plot}{BilanMigrationCar,missing}(x, color_parm = NULL,
- plot.type = "barplot", ...)
+ plot.type = "qual", ...)
}
\arguments{
\item{x}{An object of class BilanMigrationCar}
-\item{plot.type}{One of "qual", "quant" "crossed"}
+\item{plot.type}{One of "qual", "quant" "crossed" default to qual}
\item{...}{Additional parameters}
Modified: pkg/stacomir/man/setasqualitative-BilanMigrationCar-method.Rd
===================================================================
--- pkg/stacomir/man/setasqualitative-BilanMigrationCar-method.Rd 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/man/setasqualitative-BilanMigrationCar-method.Rd 2017-04-10 18:28:50 UTC (rev 352)
@@ -20,4 +20,5 @@
}
\author{
Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
+ @export
}
Modified: pkg/stacomir/man/supprime-BilanAgedemer-method.Rd
===================================================================
--- pkg/stacomir/man/supprime-BilanAgedemer-method.Rd 2017-04-07 15:32:11 UTC (rev 351)
+++ pkg/stacomir/man/supprime-BilanAgedemer-method.Rd 2017-04-10 18:28:50 UTC (rev 352)
@@ -5,7 +5,7 @@
\alias{supprime,BilanAgedemer-method}
\title{supprime method for BilanMigrationInterannuelle class}
\usage{
-\S4method{supprime}{BilanAgedemer}(object)
+\S4method{supprime}{BilanAgedemer}(object, silent = FALSE)
}
\arguments{
\item{object}{An object of class \link{BilanAgedemer-class}}
More information about the Stacomir-commits
mailing list