nrow()
Published Oct 7, 2022
Contribute to Docs
The nrow()
function returns the number of rows in a data frame.
Syntax
nrow(df_object)
The df_object
parameter is the data frame passed into the nrow()
function.
Example
The following example uses a CSV file named supplies.csv
with the following information:
Item | Quantity Needed | Price |
---|---|---|
Brooms | 15 | 8.5 |
Bucket | 3 | 4 |
Cloth | 6 | 2 |
Duster | 10 | 5.5 |
Mop | 5 | 10 |
The data within the file can be read in with the read.csv()
function and the nrow()
function can be used to retrieve the number of rows:
# Read filedf <- read.csv("supplies.csv")# Retrieve number of rowsnrow(df)
This results in the following output:
5
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.