
Last chance! 50% off unlimited learning
Sale ends in
vector
or matrix or a data frameReturns the dimension (i.e., number of columns) of x
, which is a matrix or a vector
or a data
frame. This is different than the dim
function in the base distribution of R
, in the sense that,
dimension
gives only the number of columns of the argument x
, while dim
gives the number of rows and
columns of x
.
dimension
also works for a scalar or a vector, while dim
yields NULL
for such arguments.
dimension(x)
A vector
or a matrix or a data frame whose dimension is to be determined.
Dimension (i.e., number of columns) of x
# NOT RUN {
dimension(3)
dim(3)
A<-c(1,2)
dimension(A)
dim(A)
B<-c(2,3)
dimension(rbind(A,B,A))
dimension(cbind(A,B,A))
M<-matrix(runif(20),ncol=5)
dimension(M)
dim(M)
dat.fr<-data.frame(a=A,b=B)
dimension(dat.fr)
dim(dat.fr)
dimension(c("a","b"))
# }
Run the code above in your browser using DataLab