Hi Luis,

Are you looking for the number of missings in each column?  If so, try
this:-

> bob<-matrix(c(2:4, NA, 5:7, NA), ncol=2)
> colSums(is.na(bob))
[1] 1 1

Hope this helps,
Ian.

mangosolutions
R Consulting and Training Services
Tel +44 118 902 6620
Fax +44 118 902 6401

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Luis Rideau Cruz
Sent: 15 October 2004 12:01
To: r-help@stat.math.ethz.ch
Subject: [R] length with missing values

R-help

I have a martix with missing values( in which I want the sample size by
column)
When I :

apply(matrix,2,length)

I get the length of the vector regardless of missing values.
I can't pass an argument to length in apply.

Alternatively I could 

ifelse ( is.na ( matrix [, "columns in matrix " ] ) , 0 , 1)

Is there any easier way?

Thank you

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html


	[[alternative HTML version deleted]]


