Data Frame Dimensions

We wish to get the number of rows and / or the number of columns of a data frame.

Shape

We wish to obtain both the number of rows and number of columns of a data frame.

df %>% dim()

Here is how this works:

  • We pass the data frame df to the function dim().
  • dim() returns a two element vector where the first element is the number of rows of the data frame and the second element is the number of columns.

Row Count

We wish to obtain the number of rows of a data frame.

df %>% nrow()

Here is how this works:

  • We pass the data frame df to the function dim().
  • nrow() returns the number of rows of the data frame (as an integer).

Column Count

We wish to obtain the number of columns of a data frame..

df %>% ncol()

Here is how this works:

  • We pass the data frame df to the function dim().
  • ncol() returns the number of columns of the data frame (as an integer).
R
I/O