[R] how to count the columns of a data.frame

Chuck Cleland ccleland at optonline.net
Fri Apr 14 19:09:17 CEST 2006


?ncol

ncol(data.frame(x=-1, y=0, z=1))
[1] 3

giacomo moro wrote:
> Hi,
>   I would like to count the columns of a data.frame. I know how to count the rows, but not the columns.
>   Can someone tell me how to do it?
>   My best regards,
>             Giacomo Moro
>    
> 
> 		
> ---------------------------------
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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
> 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
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