Skip to content

Check values in colums matrix

2 messages · Bill Venables, PIKAL Petr

#
As a minor footnote to both of these, I would add that both assume
that all the columns of the dataset are numeric.  It doesn't cost much
to generalize it to cover any matrix structure, of any mode:

constantColmuns <- function(Xmat) 
    which(apply(Xmat, 2, function(z) length(unique(z)) == 1))
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Berton Gunter
only
course, and
still
column
#
Hi

and if speed is an issue and object is numeric matrix something like

function(x) which(colSums(abs(diff(x)))==0)

is a little bit quicker

Cheers
Petr
On 25 Aug 2006 at 13:39, Bill.Venables at csiro.au wrote:
Date sent:      	Fri, 25 Aug 2006 13:39:48 +1000
From:           	<Bill.Venables at csiro.au>
To:             	<gunter.berton at gene.com>, <ggrothendieck at gmail.com>,
	<msubianto at gmail.com>
Copies to:      	r-help at stat.math.ethz.ch
Subject:        	Re: [R] Check values in colums matrix
Petr Pikal
petr.pikal at precheza.cz