[R] count value

Chuck Cleland ccleland at optonline.net
Thu Sep 11 14:22:41 CEST 2008


On 9/11/2008 8:11 AM, Alfredo Alessandrini wrote:
> Hi,
> 
> I've this data.frame:
> 
>> dia
>   X1006109F X1006110F X1006111F X1006112F X1006113F X1006114F X1006115F
> 1        NA        NA        NA        NA        NA        45        NA
>   X1006116F X1006117F X1006118F X1006119F X1006120F X1006122F X1006123F
> 1        45        NA        NA        NA        40        NA        NA
>   X1006124F X1006125F X1006126F X1006128F X1006203F X1006209F X1006210F
> 1        NA        NA        NA        NA        55        NA        NA
>   X1006211F X1006212F X1006213F X1006215F X1006217F X1006218F X1006219F
> 1        NA        NA        NA        NA        NA        NA        NA
>   X1006222F X1006223F X1006224F X1006225F X1006226F X1006227F X1006228F
> 1        NA        NA        NA        NA        NA        NA        NA
>   X1006301F X1006302F X1006304F X1006307F X1006308F X1006321F X1006401F
> 1        NA        NA        40        NA        NA        NA        NA
>   X1006402F X1006406F X1006407F X1006408F X1006421F X1006605F
> 1        NA        65        NA        NA        NA        45
> 
> 
> How can I count the field =! NA??

colSums(!is.na(dia))
rowSums(!is.na(dia))

> Alfredo
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894



More information about the R-help mailing list