nrow
nrow
is a function that returns the number of rows of a matrix, vector, array or data frame.
Examples
How do I get the number of rows of a dataset?
Click to see solution
Let’s first take a look at our dataset.
# Getting R Biochemical Oxygen Demand Dataset
BOD
Time demand
1 1 8.3
2 2 10.3
3 3 19.0
4 4 16.0
5 5 15.6
6 7 19.8
Since we have 6 rows, we want our nrow function to return the value 6
. Let’s try it out!
nrow(BOD)
[1] 6