Get the number of columns of an Object in R Programming - ncol() Function Last Updated : 26 Feb, 2021 Comments Improve Suggest changes Like Article Like Report ncol() function in R Language is used to return the number of columns of the specified matrix. Syntax: ncol(x)Parameters: x: matrix, vector, array or data frame Example 1: Python3 # R program to illustrate # ncol function # Getting R Biochemical Oxygen Demand Dataset BOD # Calling ncol() function to # get the number of columns ncol(BOD) Output: Time demand 1 1 8.3 2 2 10.3 3 3 19.0 4 4 16.0 5 5 15.6 6 7 19.8 [1] 2 Example 2: Python3 # R program to illustrate # ncol function # Specifying a matrix x <- matrix(c(1, 2, 3, 4), 2, 2) # Calling the ncol() function ncol(x) Output: [1] 2 Comment More infoAdvertise with us Next Article Get the number of columns of an Object in R Programming - ncol() Function K Kanchan_Ray Follow Improve Article Tags : R Language R DataFrame-Function R Object-Function R Matrix-Function Similar Reads Get the number of rows of an Object in R Programming - nrow() Function nrow() function in R Language is used to return the number of rows of the specified matrix. Syntax: nrow(x)Parameters: x: matrix, vector, array or data frame  Example 1:  Python3 # R program to illustrate # nrow function # Getting R Biochemical Oxygen Demand Dataset BOD # Calling nrow() function 1 min read Get or Set names of Elements of an Object in R Programming - names() Function names() function in R Language is used to get or set the name of an Object. This function takes object i.e. vector, matrix or data frame as argument along with the value that is to be assigned as name to the object. The length of the value vector passed must be exactly equal to the length of the obj 2 min read Get the Maximum element of an Object in R Programming - max() Function max() function in R Language is used to find the maximum element present in an object. This object can be a Vector, a list, a matrix, a data frame, etc.. Syntax: max(object, na.rm) Parameters: object: Vector, matrix, list, data frame, etc. na.rm: Boolean value to remove NA element. Example 1: Python 1 min read Getting a Matrix of number of columns in R Programming - col() Function col() function in R Language is used to get a matrix which contains the number of columns of the matrix passed to it as argument. Syntax: col(x, as.factor=FALSE) Parameters: x: matrix as.factor: a logical value indicating whether the value should be returned as a factor of column labels (created if 2 min read Get the Number of Levels of a Factor in R Programming - nlevels() Function nlevels() function in R Language is used to get the number of levels of a factor. Syntax: nlevels(x) Parameters: x: Factor Object Example 1: Python3 1== # R program to get the number # of levels of a factor # Creating a factor x <- gl(3, 2) x # Calling nlevels() function # to get the number of le 1 min read Like