[R] infinite recursion problem

Mathieu Ros mathieuros at bigfoot.com
Wed Mar 8 22:52:46 CET 2000


hello r-users,
sorry for asking a long question that may not be very relevant for the
list but it's upsetting me and I get no other solution...

I get a function HTMLExport.lm that uses another function called
HTMLExport.list.
My problem is that function HTMLExport.list works fine when used alone
but HTMLExport.lm crashes with the following error :

> HTMLExport(iris.lm)
lm(formula = Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width)
Error in names.default(x) : evaluation is nested too deeply: infinite
recursion?

Here is the code of HTMLExport.list :
"HTMLExport.list"<-
function(x, prefix = "", File = "", Align = "left", ...)
{
 xlen <- length(x)
 if(xlen == 0) {
  cat("list()\n")
  return(invisible(x))
 }
 n <- names(x)
 if(is.null(n))
  this <- paste(prefix, "[[", 1:xlen, "]]", sep = "")
 else this <- paste(prefix, "$",names(x), sep = "")
 for(i in 1:xlen) {
  this[i] <- substring(this[i], 2, nchar(this[i]))
  cat(paste("<P ALIGN=", Align,
   "><TABLE BORDER=0><TD BGCOLOR=E4E4E4><FONT FACE=ARIAL><B>",
   this[i], "</TD></TABLE></P>", sep = ""), file = File,
   append = T, sep = "")
  HTMLExport(x[[i]], File = File, prefix = this[i], ...)#here is the
problem according to debug()
 }
 invisible(x)
}


In Splus4 version of these function, the problem had been fixed using
this <- paste(prefix, "$", .C("names_unlex",n,as.integer(xlen))[[1]],
sep = "")
instead of
this <- paste(prefix, "$",names(x), sep = "")
but it can't work within R...

Could someone explain me what happens (even if I have a vague idea)
and/or give me a tip to handle this problem.

Also, I get Splus5.1 (linux mandrake7.0) and can't find a way to use
.C("names_unlex",...), could someone explain me what it does and where
to find the code (if it's not a Splus4 feature?).

thanks a lot,
    Mathieu

--
----------------------------------------------------------------------
Mathieu Ros
DESS ingénierie mathématique (biostatistiques)
Universite Joseph Fourier, Grenoble
----------------------------------------------------------------------
l'expérience est le nom que chacun donne a ses erreurs. Wilde



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list