Search notes:

R function: nrow

Counting observations in a data frame

nrow can be used to count the number of observations in a data frame.
df <- data.frame (
  col_1 = 1:5,
  col_2 = letters[1:5] 
)

df
#   col_1 col_2
# 1     1     a
# 2     2     b
# 3     3     c
# 4     4     d
# 5     5     e

nrow(df)
# [1] 5
Github repository about-r, path: /functions/nrow.R
The number of columns in a data frame can be queried with length().

See also

Index to (some) R functions

Index