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

ronggui ronggui.huang at gmail.com
Fri Apr 14 19:08:09 CEST 2006


> da<-data.frame(x=rnorm(10),y=rnorm(10))
> ncol(da)
[1] 2

or

> dim(da)[2]
[1] 2


2006/4/15, giacomo moro <gmbegnis at yahoo.it>:
> 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
>


--
»ÆÈÙ¹ó
Deparment of Sociology
Fudan University




More information about the R-help mailing list