From hb at stat.berkeley.edu  Fri May  5 20:58:19 2006
From: hb at stat.berkeley.edu (Henrik Bengtsson (max 7Mb))
Date: Fri, 5 May 2006 11:58:19 -0700
Subject: [Rd] str() with attr(*, "names") is extremely slow for long vectors
Message-ID: <59d7961d0605051158x4e482d93y780a428a494eacdc@mail.gmail.com>

Hi,

I noticed some time ago that, for instance, named vectors that are
really makes str() really slow when displaying the names attribute.  I
don't know exactly when this started, but it wasn't the case say 1-2
years ago.  Example (on a WinXP 1.8GHz):

> s <- 1:1000; names(s) <- s
> system.time(str(s))
 Named int [1:1000] 1 2 3 4 5 6 7 8 9 10 ...
 - attr(*, "names")= chr [1:1000] "1" "2" "3" "4" ...
[1] 0.08 0.00 0.09   NA   NA

> s <- 1:100000; names(s) <- s
> system.time(str(s))
 Named int [1:100000] 1 2 3 4 5 6 7 8 9 10 ...
 - attr(*, "names")= chr [1:100000] "1" "2" "3" "4" ...
[1] 8.82 0.00 9.11   NA   NA

I looks like all strings elements are processed although only the
first few are displayed.

Cheers

Henrik



[Rd] str() with attr(*, "names") is extremely slow for long vectors
Henrik Bengtsson (max 7Mb