R语言mode() str() class()辨析

Python024

R语言mode() str() class()辨析,第1张

1、mode()会输出一个R对象的基本数据类型(模式)

R可以处理的数据类型(types)(也叫模式(modes))包括数值型、字符型、布尔型、复数型(虚数)和原生型(字节)。

2、str()函数会输出一个R对象的结构

基本的数据结构(向量、矩阵、数组、数据框、因子、列表)

3、class()查看某对象的类型

class:是一种抽象类型,或者理解为一种数据结构(数据框,因子,列表)

他主要是用来给泛型函数(参考java中泛型的概念)识别参数用。

patientID <- c(1, 2, 3, 4)

age <- c(25, 34, 28, 52)

diabetes <- c("Type1","Type2","Type1","Type1")

status <- c("Poor","Improved","Excellent","Poor")

patientdata <- data.frame(patientID, age, diabetes,status)

关于r语言中find函数的用法:

find(matlab)

find()所属R语言包:matlab

描述----------Description----------

Finds indices of elements.

查找的元素的索引。

用法----------Usage----------

find(x)

参数----------Arguments----------

参数:x

expression to evaluate

要计算的表达式

Details

If expression is not logical, finds indices of nonzero elements of argument x.

如果是不符合逻辑的表达,发现指数的非零元素的参数x。

值----------Value----------

Returns indices of corresponding elements matching the expression x.

返回指数的相应匹配的元素的表达x。

P. Roebuck <a href="mailto:[email protected]"[email protected]</a>

实例

----------Examples----------

find(-3:3 >= 0)

find(c(0, 1, 0, 2, 3))