R語言學習筆記(一):mode, class, typeof的區別


要了解這三個函數的區別,先了解numeric, double與integer.

在r中浮點數有兩個名字叫numeric與double.
double是指它的類型(type)名字,numeric是指它的模式(mode)名字,同時也是類(class)的名字。

mode

mode中將integer和double顯示為numeric

class

mode是指變量的類型如:數值型、字符型、邏輯型等
class是指變量的類別如:矩陣、列表、數據框等

typeof

typeof是對變量類型的細分

> mode(3)
[1] "numeric"
> mode(3L)
[1] "numeric"

> class(3L)
[1] "integer"
> class(3)
[1] "numeric"

> typeof(3)
[1] "double"
> typeof(3L)
[1] "integer"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM