R 語言中的 class() 函數用於返回用作參數的數據類。
用法: class(x)
參數:
x:指定數據
範例1:
# R program to illustrate
# class function
# Specifying "Biochemical oxygen demand"
# data set
x <- BOD
x
# Calling class() function
class(x)
輸出:
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] "data.frame"
範例2:
# R program to illustrate
# class function
# Calling class() function
# over different types of data
class(2)
class(2.8)
class("3")
class("gfg")
class(1 + 2i)
輸出:
[1] "numeric" [1] "numeric" [1] "character" [1] "character" [1] "complex"
相關用法
- R語言 typeof()用法及代碼示例
- R語言 data.matrix()用法及代碼示例
- R語言 with()用法及代碼示例
- R語言 sample()用法及代碼示例
- R語言 determinant()用法及代碼示例
- R語言 length()用法及代碼示例
- R語言 charmatch()用法及代碼示例
- R語言 col()用法及代碼示例
- R語言 det()用法及代碼示例
- R語言 row()用法及代碼示例
- R語言 strftime()用法及代碼示例
- R語言 density()用法及代碼示例
- R語言 outer()用法及代碼示例
注:本文由純淨天空篩選整理自Kanchan_Ray大神的英文原創作品 Getting class of different data types in R Programming – class() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。