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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Luis Rideau Cruz
Sent: 15 October 2004 12:01
To: [EMAIL PROTECTED]
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

______________________________________________
[EMAIL PROTECTED] 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]]

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

Reply via email to