[Stacomir-commits] r270 - pkg/stacomir/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 1 13:48:12 CET 2017


Author: briand
Date: 2017-02-01 13:48:12 +0100 (Wed, 01 Feb 2017)
New Revision: 270

Modified:
   pkg/stacomir/R/BilanArgentee.r
   pkg/stacomir/R/Bilan_poids_moyen.r
Log:
fix of a potential bug in bilanArgentee, this bug occurs when only one instance of qualitative factor appeared, changing the structure of the list.

Modified: pkg/stacomir/R/BilanArgentee.r
===================================================================
--- pkg/stacomir/R/BilanArgentee.r	2017-01-31 20:40:27 UTC (rev 269)
+++ pkg/stacomir/R/BilanArgentee.r	2017-02-01 12:48:12 UTC (rev 270)
@@ -195,7 +195,6 @@
 #' @param silent Boolean, if TRUE, information messages are not displayed, only warnings and errors
 #' @author Cedric Briand \email{cedric.briand"at"eptb-vilaine.fr}
 setMethod("calcule",signature=signature("BilanArgentee"),definition=function(object,silent) {
-			#bilanArg<-b_carlot
 			bilanArg<-object
 			if(nrow(bilanArg at data)==0) {
 				funout(gettext("No data of silver or yellow eel on the selected period",domain="R-stacomiR"), arret=TRUE)
@@ -240,7 +239,17 @@
 				# now matquant2 only contain the correct columns
 				# matqual has two column for a single qualitative variable, which is wrong
 				# we will merge them
+				
+				# however there is a bug if only one value is present
+				# depending on the data structure there might a bug
+				# when there is only one dimension (ie on instance of factor where there should be two)
+				for (z in 1:length(matqual2)){		
+					if (is.null(dim(matqual2[[z]])[2])) matqual2[[z]]<-cbind(matqual2[[z]],NA)
+				}
 				matqual3<-matrix(NA,nrow=nrow(matqual2[[1]]),ncol=length(parqual))
+				# below if the data in  the first column is NA we choose the second
+				# which migh also be NA in which case the result becomes a NA
+				
 				for (j in 1:length(parqual)){
 					theparqual=parqual[j]
 					matqual3[,j]<-apply(matqual2[[theparqual]],1,function(X) ifelse(is.na(X[1]),X[2],X[1]))

Modified: pkg/stacomir/R/Bilan_poids_moyen.r
===================================================================
--- pkg/stacomir/R/Bilan_poids_moyen.r	2017-01-31 20:40:27 UTC (rev 269)
+++ pkg/stacomir/R/Bilan_poids_moyen.r	2017-02-01 12:48:12 UTC (rev 270)
@@ -171,7 +171,7 @@
 #' @param h handler
 #' @param \dots additional arguments passed to the function
 hcalc = function(h,...) {
-	bilPM<-get("bilPM",envir=envir_stacomi)
+	bilPM<-get("bilan_poids_moyen",envir=envir_stacomi)
 	bilPM<-charge(bilPM)
 	bilPM<-connect(bilPM)
 	bilPM<-calcule(bilPM)
@@ -494,6 +494,7 @@
 
 #
 funtableBilan_poids_moyen = function(h,...) {
+	bilPM<-get("bilan_poids_moyen",envir=envir_stacomi)
 	bilPM=charge(bilPM)  
 	donnees=bilPM at data # on recupere le data.frame  
 	assign("bilan_poids_moyen",bilPM,envir_stacomi)



More information about the Stacomir-commits mailing list