View Interactive Version
nrow(___) ncol(___) dim(___) length(___)
The number of rows and columns in a data frame can be guessed through the printed output of the data frame. However, it is much easier to get this information directly through functions. Additionally, you might want to use this information in some parts of the code.
Data frames have two dimensions. The number of rows is considered to be the first dimension. It typically defines the number of observations in a data set. To get the number of rows from the
Davis data frame in the carData dataset use the
Similarly, the number of columns or attributes of the data frame can be retrieved with