[Rd] Error: cannot set length of non-vector

Kurt Hornik Kurt.Hornik at wu-wien.ac.at
Mon Apr 4 11:16:58 CEST 2005


>>>>> Charles Geyer writes:

> On Sun, Apr 03, 2005 at 09:13:56AM -0400, Duncan Murdoch wrote:
>> On Sat, 2 Apr 2005 23:50:24 -0600, Charles Geyer
>> <charlie at stat.umn.edu> wrote :
>> 
>> >The subject line says it all.  How can I find what
>> >
>> >    Error: cannot set length of non-vector
>> >
>> >means?  RTFS is no help.  I can find out of course that
>> >it comes from "lengthgets", but who called that?  Not me!
>> 
>> I think the error comes from your second chunk where you have
>> read.table("logit.txt", header=T).  I don't think CHECK is running in
>> the right directory to find the file.
>> 
>> Whether this is your bug or CHECK's bug, I don't know.
>> 
>> It certainly would be nice if CHECK errors were easier to diagnose.
>> I'm not sure my diagnosis is right, because I was just trying to
>> manually duplicate bits of the CHECK script, and I might have missed a
>> setwd somewhere.

> No.  That's not it.  (I'm almost sure.)

> I've rewritten the read.table to read from the web.  Now there are no local
> reads.  Of course there are local writes to the eps and pdf files for
> figures that it builds.

> But even more important, despite the "error" the vignette is created just
> fine (see the bottom of the new, just redone)

>     http://www.stat.umn.edu/geyer/mcmc/package/typescript

> No difference in the two tex files (produced by R CMD build and R CMD check)
> except for timing stuff.  Furthermore

>     http://www.stat.umn.edu/geyer/mcmc/package/mcmc.Rcheck/mcmc/doc/demo.pdf

> looks o. k. to me.  (All the figures are there, for example).
> I can't do a diff on pdf's but it seems like the error is not in
> the vignette or in Sweave but in the plumbing (or in some weird interaction
> of all of the above -- or in something I can't imagine).

> For anyone else interested, the package (just rebuilt) is

>     http://www.stat.umn.edu/geyer/mcmc/package/mcmc_0.5.tar.gz

After playing with this some time ...

I get the same error when I run R CMD check from the command line.
I do not get the error when I use Stangle() to create demo.R and run
this either interactively, or via R CMD BATCH using --vanilla, or not.

The error comes from

SEXP lengthgets(SEXP x, R_len_t len)
{
    R_len_t lenx, i;
    SEXP rval, names, xnames, t;
    if (!isVector(x) && !isVectorizable(x))
	error(_("cannot set length of non-vector"));

in src/main/builtin.c.  I see no way to globally turn on dumping call
stack info at the C level to actually see where in the code the error
triggers.  If I add debugging info prior to the error call, the error is
gone.

Btw, if I comment *output* redirection in tools::checkVignettes(), the
error is gone as well.

Note that this is *NOT* an error thrown by R CMD check.  The failure
occurs when checkVignettes() is running the code (via source()) of the
.R files created via Stangle(), and all the info we have about the error
is being passed on.

-k



More information about the R-devel mailing list