[R] "Error: bad value" problem

Richard E. Chandler richard at stats.ucl.ac.uk
Wed Dec 17 23:34:04 CET 2008


Dear R-help,

Like several other subscribers, I have recently encountered a problem 
whereby R will execute code apparently correctly and without error, 
but any subsequent command will yield "Error: bad value" so that R 
has to be killed and restarted. We have checked this out with a few 
different operating systems (Windows XP/Vista and Linux) and with 
different versions of R. We have established the following:

1.	The error occurs with versions of R from 2.5.0 onwards on all the 
OSs we have tried, but not with earlier versions of R.
2.	The error is not reproducable between machines - identical code 
will fail at different points on two different machines.
3.	The error is not related to contributed packages, because our code 
doesn't use any. The code *does*, however, use repeated calls to 
optim() and nlm(), and passes several arguments through a sequence of 
functions using "...".
4.	Occasionally, we get an error relating to subset replacement 
instead of "Error:bad value". For example:

 > x <- rnorm(10)
 > x[1] <- 3
Error in x[1] <- 3 : could not find function "[<-"

5.	The error behaviour changes as a result of minor modifications to 
print() statements in the code e.g. by inserting a line that prints 
the value of a well-defined variable.

I suspect this really *is* a bug (particularly since it only started 
happening with version 2.5.0), but I figure it would be worth giving 
people a chance to tell me I'm an idiot before reporting it as such. 
In case anybody would like to try and see the error for themselves, I 
have uploaded some files to 
http://www.homepages.ucl.ac.uk/~ucakarc/Rtest/. The file ErrorDemo.r 
is the main script - see the file header there for more details. 
Files momfit.r and elmstats.dat are also required for this example to 
work. I'm sorry that it isn't a very simple example, but I haven't 
seen a simple illustration of the problem (and I couldn't find any 
examples in the list archives either).

With best wishes to all,
Richard
=====================================================================
			Richard E. Chandler
			^^^^^^^^^^^^^^^^^^^
Room 135, Dept of Statistical Science, University College London,
1-19 Torrington Place, London WC1E 6BT, UK
Tel: +44 (0)20 7679 1880		Fax: +44 (0)20 7383 4703

Internet: http://www.ucl.ac.uk/Stats       		(department)
           http://www.homepages.ucl.ac.uk/~ucakarc	(personal)
email:    richard at stats.ucl.ac.uk



More information about the R-help mailing list