[R] logic operation on an array
Charles C. Berry
cberry at tajo.ucsd.edu
Tue Aug 28 20:37:16 CEST 2007
an array is just a vector with attributes.
> all ( diag(2) == 0 )
> all ( diag(2)*0 == 0 )
On Tue, 28 Aug 2007, Gang Chen wrote:
> I want to check whether all the components of a vector (or an array)
> are 0, and if they are I will skip the later computations. Of course
> I can create a loop to go through all the components. However is
> there an R function for this purpose more efficient than looping?
> Thanks a lot,
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help