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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758201036, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/nrow(61): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78