On Tue, 25 Oct 2005, Jennifer Lai wrote:
> Hi,
>Is nchar function knowingly slow in R? I'm doing some string
> formatting that requires multiple call to nchar, and nchar seems to be
> very slow.
Is 70 usec 'very slow'?
Both nchar and sprintf are vectorized, so why not make use of that?
> st
Hi,
Is nchar function knowingly slow in R? I'm doing some string
formatting that requires multiple call to nchar, and nchar seems to be
very slow.
Experiment 1, pass nchar inside sprintf, and it takes 0.7 seconds
> system.time(for (i in 1:1)
+ str = sprintf('0005%020d', nchar(op))
+ )[3