# Determine the size of a data frame

June 9, 2020
By • Get number of rows of a data frame
• Get number of columns of a data frame
• Get dimensions of a data frame
`nrow(___) ncol(___) dim(___) length(___)`

## Data Frame Dimensions

`nrow(___) ncol(___) dim(___) length(___)`

`nrow（戴维斯）`
` 200`

Similarly, the number of columns or属性of the data frame can be retrieved with`的NcoI（）`:

`ncol(Davis)`
` 5`

## Exercise: Determine number of elements in data frame

`survived sex age passengerClass Allen, Miss. Elisabeth Walton yes female 29 1st [ reached 'max' / getOption("max.print") -- omitted 1308 rows ]`

Start Exercise

## Retrieving data frame dimensions

`nrow(___) ncol(___) dim(___) length(___)`

To retrieve the size of all dimensions from a data frame at once you can use the`dim()`function.`dim()`returns a vector with two elements, the first element is the number of rows and the second element the number of columns.

For example, the dimensions of the`戴维斯`dataset can be retrieved as

`昏暗（戴维斯）`
` 200 5`

`dim(c(1, 3, 5, 7))`
`空值`

`length(c(1, 3, 5, 7))`
` 4`

In the case of a data frame`length()`返回其列数：

`length(Davis)`
` 5`

## 提问：数据帧尺寸

`dim(Florida)`

What does the above command return for the data set`Florida`from thecarDatapackage which has 11 columns and 67 rows?

• `67``11`
• `11``67`
• `11`
• `67`

Start Quiz

Determine the size of a data frame is an excerpt from the courseIntroduction to R, which is available for free atquantargo.com

VIEW FULL COURSE