From mtmorgan at fhcrc.org  Mon Jul 20 15:01:03 2009
From: mtmorgan at fhcrc.org (Martin Morgan)
Date: Mon, 20 Jul 2009 06:01:03 -0700
Subject: [Rd] tabulate can accept NA values?
Message-ID: <6phocrfld9s.fsf@gopher4.fhcrc.org>

tabulate has

    .C("R_tabulate", as.integer(bin), as.integer(length(bin)),
       as.integer(nbins), ans = integer(nbins), PACKAGE="base")$ans

The implementation of R_tabulate has

  	if(x[i] != R_NaInt && x[i] > 0 && x[i] <= *nbin)

and so copes with (silently drops) NA. Perhaps the .C could have
NAOK=TRUE? This is useful in apply'ing tabulate to the rows or columns
of a (large) matrix, where the work-around involves introducing some
artificial NA value (and consequently copying the matrix) outside the
range of tabulate's nbin argument.

Martin  
-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



[Rd] tabulate can accept NA values?
Martin Morgan