[R] question from Braun/Murdoch book

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Wed Oct 8 09:36:24 CEST 2008

Prof Brian Ripley wrote:
> On Wed, 8 Oct 2008, Erin Hodgess wrote:
>> Hi R People:
>> I am looking at the Braun/Murdoch book, " A First Course in
>> Statistical Programming in R", and I have a question about a function
>> there.  It's on page 52, Example 4.5; the sieve of Erastosthenes.
>> There is a line:
>> primes <- c()
>> Is there a difference between using that and
>> primes <- NULL
>> please?
>> When you put in primes <- c(), primes comes back as NULL.
>> Is one more efficient or is this just a matter of programming style,
>> please?
> What would be more efficient is primes <- integer(0) (as it looks like
> 'primes' concatenates integer vectors, at a quick glance).
> Use a function call c() to get NULL is not efficient, but all the
> differences here are tiny.

btw., is(NULL) says that NULL is of the class "NULL" and
"OptionalFunction" -- what is an OptionalFunction?

?Opt<tab> completes to ?OptionalFunction-class, but the man page does
not even mention OptionalFunction.

apropos("OptionalFunction") points to .__C__OptionalFunction, but
help.search(".__C__OptionalFunction") gives no results.  if this is a
low-level implementational detail, why should is(NULL) expose it?


More information about the R-help mailing list