R語言中的nrow()函數用於返回指定矩陣的行數。
用法: nrow(x)
參數:
x: matrix, vector, array or data frame
範例1:
Python3
# R program to illustrate
# nrow function
# Getting R Biochemical Oxygen Demand Dataset
BOD
# Calling nrow() function to
# get the number of rows
nrow(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 [1] 6
範例2:
Python3
# R program to illustrate
# nrow function
# Specifying a matrix
x <- matrix(c(1, 2, 3, 4), 1, 4)
# Calling the nrow() function
nrow(x)
輸出:
[1] 1
相關用法
- R語言 ncol()用法及代碼示例
- R語言 max()用法及代碼示例
- R語言 min()用法及代碼示例
- R語言 get()用法及代碼示例
- R語言 names()用法及代碼示例
- R語言 mode()用法及代碼示例
- R語言 row()用法及代碼示例
- R語言 sapply()用法及代碼示例
- R語言 args()用法及代碼示例
- R語言 nlevels()用法及代碼示例
- R語言 identity()用法及代碼示例
- R語言 type.convert()用法及代碼示例
- R語言 which()用法及代碼示例
- R語言 call()用法及代碼示例
- R語言 cumprod()用法及代碼示例
- R語言 is.character()用法及代碼示例
- R語言 is.factor()用法及代碼示例
- R語言 unique()用法及代碼示例
- R語言 str()用法及代碼示例
- R語言 cumsum()用法及代碼示例
- R語言 order()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Get the number of rows of an Object in R Programming – nrow() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。