[R] Infinite recursion error that I don't understand
Bert Gunter
gunter.berton at gene.com
Thu Jan 3 20:11:16 CET 2008
Many thanks, Brian. Quite right! -- traceback() should be mandatory.
I wasn't aware that some data frames cannot be printed in some
representation. I always got something out, even if uninformative.
-- Bert
-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: Thursday, January 03, 2008 10:57 AM
To: Bert Gunter
Cc: r-help at r-project.org
Subject: Re: [R] Infinite recursion error that I don't understand
The error is in printing ...
foo <- data.frame(I(z))
works. It is not hard to create a data frame you cannot print, and this
is one. It could be considered a bug in format.AsIs, which calls
toString without removing its class.
Traceback() helps:
14: format.AsIs(x, ...)
13: format(x, ...)
12: as.character.POSIXt(1199386325.312)
11: as.character(1199386325.312)
10: paste(x, collapse = ", ")
9: toString.default(x[[i]], width = width, ...)
8: toString(x[[i]], width = width, ...)
7: format.AsIs(x[[i]], ..., justify = justify)
6: format(x[[i]], ..., justify = justify)
5: format.data.frame(x, digits = digits, na.encode = FALSE)
4: as.matrix(format.data.frame(x, digits = digits, na.encode = FALSE))
3: print(as.matrix(format.data.frame(x, digits = digits, na.encode =
FALSE)),
..., quote = quote, right = right)
2: print.data.frame(list(z = c(1199386325.312, 1199386325.312,
1199386325.312,
1199386325.312, 1199386325.312)))
1: print(list(z = c(1199386325.312, 1199386325.312, 1199386325.312,
1199386325.312, 1199386325.312)))
On Thu, 3 Jan 2008, Bert Gunter wrote:
>> sessionInfo()
> R version 2.6.1 Patched (2007-12-03 r43574)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
>
> attached base packages:
> [1] grDevices datasets stats graphics grid tcltk utils
> [8] methods base
>
> ## ... + other packages..
>
>> z <- rep(Sys.time(),5)
>> data.frame(z)
> z
> 1 2008-01-03 10:19:43
> 2 2008-01-03 10:19:43
> 3 2008-01-03 10:19:43
> 4 2008-01-03 10:19:43
> 5 2008-01-03 10:19:43
>
>> data.frame(I(z))
> Error: evaluation nested too deeply: infinite recursion /
> options(expressions=)?
>
> ## I don't have a clue. Any words of wisdom would be appreciated.
>
> Bert Gunter
> Genentech
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list