[Zooimage-commits] r239 - in pkg/zooimage: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Feb 6 10:23:47 CET 2013


Author: phgrosjean
Date: 2013-02-06 10:23:47 +0100 (Wed, 06 Feb 2013)
New Revision: 239

Modified:
   pkg/zooimage/DESCRIPTION
   pkg/zooimage/NEWS
   pkg/zooimage/R/gui.R
   pkg/zooimage/R/guiutils.R
   pkg/zooimage/man/zooimage.package.Rd
Log:
Assignment to .GlobalEnv through .assignGlobal() function

Modified: pkg/zooimage/DESCRIPTION
===================================================================
--- pkg/zooimage/DESCRIPTION	2013-01-30 18:21:42 UTC (rev 238)
+++ pkg/zooimage/DESCRIPTION	2013-02-06 09:23:47 UTC (rev 239)
@@ -1,8 +1,8 @@
 Package: zooimage
 Type: Package
 Title: Analysis of numerical zooplankton images
-Version: 3.0-1
-Date: 2012-12-21
+Version: 3.0-2
+Date: 2013-02-06
 Author: Ph. Grosjean, K. Denis & R. Francois
 Maintainer: Ph. Grosjean <Philippe.Grosjean at umons.ac.be>
 Depends: R (>= 2.14.0), svMisc (>= 0.9-67), svDialogs (>= 0.9-53), mlearning

Modified: pkg/zooimage/NEWS
===================================================================
--- pkg/zooimage/NEWS	2013-01-30 18:21:42 UTC (rev 238)
+++ pkg/zooimage/NEWS	2013-02-06 09:23:47 UTC (rev 239)
@@ -1,5 +1,12 @@
 = zooimage News
 
+== Changes in zooimage 3.0-2
+
+* Assignment to .GlobalEnv is strictly restricted to GUI operations, and only
+  following direct request by the end-user through an explicit dialog box. The
+  internal function .assignGlobal() is used for that purpose.
+
+
 == Changes in zooimage 3.0-1
 
 * getTrain() was not able to collect data when attributes measured on samples

Modified: pkg/zooimage/R/gui.R
===================================================================
--- pkg/zooimage/R/gui.R	2013-01-30 18:21:42 UTC (rev 238)
+++ pkg/zooimage/R/gui.R	2013-02-06 09:23:47 UTC (rev 239)
@@ -560,13 +560,14 @@
 		return(invisible(NULL))
 	
 	## Ask for a name for this ZITrain object
-	name <- dlgInput("Name for the ZITrain object:", default = "ZItrain")$res
+	name <- dlgInput("Name for the ZITrain object to create in the global environment:",
+		default = "ZItrain")$res
 	if (!length(name)) return(invisible(FALSE))
 	name <- make.names(name)	# Make sure it is a valid name!
 	
-	## Get the training set and save it in .GlobalEnv under the given name
+	## Get the training set and save it in .GlobalEnv under the provided name
 	res <- getTrain(dir, creator = NULL, desc = NULL, keep_ = FALSE)
-	assign(name, res, envir = .GlobalEnv)
+	.assignGlobal(name, res)
 	
 	## Remember the object name
 	assignTemp("ZI.TrainName", name)
@@ -659,7 +660,7 @@
 		if (!length(ZIT) || (length(ZIT) == 1 && ZIT == ""))
 			return(invisible(NULL))
 		## Ask for a name for this ZIClass object
-		name <- dlgInput("Name for the ZIClass object to create:",
+		name <- dlgInput("Name for the ZIClass object to create in the global environment:",
 			default = "ZIclass")$res
 		if (!length(name)) return(invisible(NULL))
 		name <- make.names(name)	# Make sure it is a valid name!
@@ -770,8 +771,9 @@
 		## Calculate results using formula created by variables selection
 		res <- ZIClass(form, data = get(ZIT, envir = .GlobalEnv), algorithm = algorithm)
 	}
+	## Store the resulting object
+	.assignGlobal(name, res)
 	## Print results
-	assign(name, res, envir = .GlobalEnv)
 	print(res)
 	cat("\n")
 	## Remember that ZIClass object
@@ -1071,7 +1073,7 @@
 	brks <- eval(parse(text = brks))
 
 	## Get a name for the variable containing results
-	name <- dlgInput("Name for the ZIRes object to create:",
+	name <- dlgInput("Name for the ZIRes object to create in the global environment:",
 		default = "ZIres")$res
 	if (!length(name)) return(invisible(NULL))
 	name <- make.names(name)
@@ -1084,7 +1086,7 @@
 	
 	
 	## Assign this result to the variable
-	assign(name, res, envir = .GlobalEnv)
+	.assignGlobal(name, res)
 	## Remember the name of the variable
 	assignTemp("ZI.LastRES", name)
 }

Modified: pkg/zooimage/R/guiutils.R
===================================================================
--- pkg/zooimage/R/guiutils.R	2013-01-30 18:21:42 UTC (rev 238)
+++ pkg/zooimage/R/guiutils.R	2013-02-06 09:23:47 UTC (rev 239)
@@ -260,3 +260,9 @@
 #    tkwait.window(ZIAssist)
 #    return(getTemp("ZIret"))
 }
+
+.assignGlobal <- function (x, value)
+{
+	G <- .GlobalEnv
+	assign(x = x, value = value, envir = G)
+}

Modified: pkg/zooimage/man/zooimage.package.Rd
===================================================================
--- pkg/zooimage/man/zooimage.package.Rd	2013-01-30 18:21:42 UTC (rev 238)
+++ pkg/zooimage/man/zooimage.package.Rd	2013-02-06 09:23:47 UTC (rev 239)
@@ -16,8 +16,8 @@
   \tabular{ll}{
     Package: \tab zooimage\cr
     Type: \tab Package\cr
-    Version: \tab 3.0-1\cr
-    Date: \tab 2012-12-21\cr
+    Version: \tab 3.0-2\cr
+    Date: \tab 2013-02-06\cr
     License: \tab GPL 2 or above at your convenience.\cr
   }
   Everytime you publish results that use ZooImage, you must place a reference



More information about the Zooimage-commits mailing list