[Rd] Warnings generated by log2()/log10() are really large/takes a long time to display

Henrik Bengtsson hb at stat.berkeley.edu
Wed Feb 27 07:03:24 CET 2008


x <- rnorm(1e6);

y <- log(x);  # or logb(x) or log1p(x)
w <- warnings();
print(object.size(w));
## [1] 480
str(w);
 $ NaNs produced: language log(x)
 - attr(*, "dots")= list()
 - attr(*, "class")= chr "warnings"

y <- log2(x);  # or log10(x)
w <- warnings();
print(object.size(w));
## [1] 8000536
str(w);
## List of 1
##  $ NaNs produced: language log(c(2.12082478659910,
1.40263187453398, 1.574125429
## 83486, -0.816399069824751,  0.215940065840533, 1.20975177084379,
-0.340287874362
## 813, 0.117151537611550,  ...
##  - attr(*, "dots")= list()
##  - attr(*, "class")= chr "warnings"

Note also how long it takes to display and str() the warning.

I have observed this on R v2.6.2 and R v2.7.0 (2008-02-11 r44432) on
both WinXP and Linux.

/Henrik



More information about the R-devel mailing list