[RkWard-devel] New Plug-ins

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Jan 1 23:23:18 UTC 2007


On Monday 01 January 2007 23:42, SJR wrote:
> I checked it and unfortunately this is not what I need. Basically would it
> work conveniently  if you work with only one vector. But if you investigate
> a buch of data in a  batch any calculation will stop if only one vector is
> not in the given range. Better would be a textual output. Therefore I think
> something for the php file would make more sense. For example:
>
> if "option is for test chosen" AND "numeric vector is in range" THEN
> "perform test" ELSE "write 'Data not in Range'"

That might translate into

i <- 0
for (object in objects) {
	i <- i + 1
	if (optionx) {
		if (length (object) < 8) {
			warning ("Data not in Range")
			next		# skip object
		}

		results[i] <- do.some.test (object)
	}
}

Note in this example, that
length (object)
will return the length of the object *including* NAs, which may not be, what is needed.

Typically, the test itself will know more exactly what conditions to check for, and it may not be sensible to try to duplicate all those checks. Hence, a different approach might be:

i <- 0
for (object in objects) {
	i <- i + 1
	try ( { 	# basically "try ()" means: continue on errors
		results[i] <- do.some.test (object)
	} )
}

or (with more elaborate handling):

errors <- list ()
i <- 0
for (object in objects) {
	i <- i + 1
	tryCatch ( {
		results[i] <- do.some.test (object)
	}, error = function (e) {
		errors[[i]] <- paste (objectname, e$message, sep=": ")
	} )
}

# in printout
if (length (errors) >= 1) {
	cat ("Errors were encountered while processing the following objects:\n")
	for (error in errors) {
		cat (error, "\n")
	}
}

Does any of this help?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070102/0d76625d/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/rkward-devel/attachments/20070102/0d76625d/attachment.sig>


More information about the Rkward-devel mailing list