[Stacomir-commits] r551 - in pkg: stacomir/R stacomirtools/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Oct 25 15:43:19 CEST 2019


Author: briand
Date: 2019-10-25 15:43:18 +0200 (Fri, 25 Oct 2019)
New Revision: 551

Modified:
   pkg/stacomir/R/fun_write_monthly.R
   pkg/stacomir/R/funstat.R
   pkg/stacomir/R/report_mig.R
   pkg/stacomirtools/R/utilities.r
Log:
Fixed two bugs, one in report_mig where there has to be at least one line with no NULL values (i.e.) if there is a report with a single day when you have +1 and -1 it created problems. The second bug is about the data structure in monthly report when there is just a single month (funstat)

Modified: pkg/stacomir/R/fun_write_monthly.R
===================================================================
--- pkg/stacomir/R/fun_write_monthly.R	2019-10-22 16:11:21 UTC (rev 550)
+++ pkg/stacomir/R/fun_write_monthly.R	2019-10-25 13:43:18 UTC (rev 551)
@@ -12,9 +12,6 @@
   # voir essai_table_reportmensuel.sql pour le format du tableau
   # below not the most elegant way to do it but efficient
   
-  # bug 2019 the function does not work if only one month is reported
-  # for this reason we only launch the fun_write_month with col >3
-  # TODO manage this bug
  t_reportmigrationmensuel_bme=stacomirtools::killfactor(
 	  cbind(report_mig at dc@dc_selectionne,
 		  report_mig at taxa@data$tax_code,

Modified: pkg/stacomir/R/funstat.R
===================================================================
--- pkg/stacomir/R/funstat.R	2019-10-22 16:11:21 UTC (rev 550)
+++ pkg/stacomir/R/funstat.R	2019-10-25 13:43:18 UTC (rev 551)
@@ -27,7 +27,7 @@
 	Poids_total=poids_depuis_effectif+ poids_mesure
 	resum=rbind(somme,moyennes_journalieres,poids_depuis_effectif,poids_mesure,Poids_total)		
   }
-  resum=resum[,moislab]
+  resum=resum[,moislab, drop=FALSE]
   resum=as.data.frame(resum)
   resum["somme","report"]=round(sum(tableau$Effectif_total, na.rm=TRUE),2)
   resum["moyennes_journalieres","report"]=mean(tableau$Effectif_total,na.rm=TRUE)

Modified: pkg/stacomir/R/report_mig.R
===================================================================
--- pkg/stacomir/R/report_mig.R	2019-10-22 16:11:21 UTC (rev 550)
+++ pkg/stacomir/R/report_mig.R	2019-10-25 13:43:18 UTC (rev 551)
@@ -627,6 +627,8 @@
 	  if (class(silent)!="logical") stop("the silent argument should be a logical")
 	  dc=as.numeric(report_mig at dc@dc_selectionne)[1]
 	  data=report_mig at calcdata[[stringr::str_c("dc_",dc)]][["data"]]
+		# keep one line if there is one species in one day with as much up as down...
+		if (nrow(data)>1)
 	  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))
@@ -633,6 +635,7 @@
 	  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
 	  data$taux_d_echappement[data$taux_d_echappement==-1]<-NA 

Modified: pkg/stacomirtools/R/utilities.r
===================================================================
--- pkg/stacomirtools/R/utilities.r	2019-10-22 16:11:21 UTC (rev 550)
+++ pkg/stacomirtools/R/utilities.r	2019-10-25 13:43:18 UTC (rev 551)
@@ -69,7 +69,7 @@
 		new_variable_name){
 		if (length(old_variable_name)!=length(new_variable_name)) stop("les variables de remplacement doivent avoir le meme nombre que les variables de depart")
 		if (!all(!is.na(match(old_variable_name,colnames(object))))) {
-		   stop(paste("les noms",paste(is.na(match(old_variable_name,colnames(object))),collapse="/"),"ne correspondent pas aux variables du tableau"))
+		   stop(paste("les noms",paste(old_variable_name[is.na(match(old_variable_name,colnames(object)))],collapse="/"),"ne correspondent pas aux variables du tableau"))
     }
 	colnames(object)[match(old_variable_name,colnames(object))]<- new_variable_name
 	return(object)



More information about the Stacomir-commits mailing list