From rgentlem at fhcrc.org  Tue Jul 21 03:36:21 2009
From: rgentlem at fhcrc.org (Robert Gentleman)
Date: Mon, 20 Jul 2009 18:36:21 -0700
Subject: [Rd] tabulate can accept NA values?
In-Reply-To: <6phocrfld9s.fsf@gopher4.fhcrc.org>
References: <6phocrfld9s.fsf@gopher4.fhcrc.org>
Message-ID: <4A651B95.9020903@fhcrc.org>

should be in devel now, NAs are ignored (as are non-integers and things 
outside the nbin argument)

Martin Morgan wrote:
> 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  

-- 
Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
PO Box 19024
Seattle, Washington 98109-1024
206-667-7700
rgentlem at fhcrc.org



[Rd] tabulate can accept NA values?
Robert Gentleman