The nrow() function is used to get number of rows in data frame, matrix or table like structure.

The following method shows how you can do it with syntax.

Method: Use nrow() Function

nrow(df)

Let’s see example using nrow() function.

Use nrow() Function to Get Number of Rows of Data Frame

Suppose we have data frame and want to find number of rows of data frame:

# Create data frame
df <- data.frame(Machine_name=c("A","B","C","D","A","A","G","B"),
                 Temperature=c(12,9,NA,13,18,28,22,23),
                 Pressure=c(20,25,27,29,30,32,39,40))

# Find total number of rows
nrow(df)

Output:

[1] 8

Here the nrow() function return 8 because data frame having 8 rows.