本体对象属性和数据属性区别_数据类型r对象和属性

news/2024/7/10 2:32:48 标签: java, python, vue, javascript, js

本体对象属性和数据属性区别

In this article we’ll cover an important issue for R. We will talk about the different types of data used in R. We will also learn about some basic operations on data types.

在本文中,我们将介绍R的重要问题。我们将讨论R中使用的数据的不同类型。我们还将学习有关数据类型的一些基本操作。

如果您准备好了,那就开始吧: (If you’re ready, let’s get started:)

对象 (Objects)

Everything you manipulate in R, everything we encounter in R, objects that can be called objects, objects can all be of different types, contain all different types of data. But everything in R is an object. So R has five basic classes of atomic objects. These are fairly low levels or basic object classes, character, numeric. So these are like real numbers or decimal numbers, integers, complex numbers, and logicals

您在R中操作的所有内容,在R中遇到的所有内容,可以称为对象的对象,对象都可以具有不同的类型,包含所有不同类型的数据。 但是R中的所有东西都是对象。 因此,R具有原子对象的五种基本类别。 这些是相当低的级别或基本对象类,字符,数字。 所以这些就像实数或十进制数,整数,复数和逻辑

The most basic object in R is called a vector. One thing you cannot do with a standard vector is have mixed types of objects you cannot have a vector of characters and numerics, or numerics and integers, or integers and logicals. And everything in a vector has to be the same class.

R中最基本的对象称为向量。 标准向量不能做的一件事是具有混合类型的对象,您不能拥有字符和数字,数字和整数或整数和逻辑的向量。 向量中的所有内容都必须是同一类。

Somtimes there’s one type of vector that can have multiple different types of classes. This is a “list”. So a list is represent as a vector, it’s a sequence of objects. But each element of that vector can be a different and ofcourse can be an object of a different class. You can have a list that’s inside the list and one element of the list can be a data frame so, any element of the list can be anything. You can be created directly from expressions using the quote mechanism and converted to and from lists by the as.list and as.call functions.

有时,向量的一种类型可以具有多种不同类型的类。 这是一个“列表”。 因此,列表表示为向量,它是一系列对象。 但是该向量的每个元素可以不同,并且当然可以是不同类的对象。 您可以在列表内有一个列表,并且列表的一个元素可以是一个数据框,因此列表的任何元素都可以是任何东西。 可以使用引号机制从表达式直接创建您,并通过as.listas.call函数在列表之间进行转换。

Also you can create an empty vector with the vector function. And the vector function has two basic arguments. The first argument is the class of the object, so the type of object that you want to have in the vector. And the second argument is the length of the vector itself. R has six basic (‘atomic’) vector types: logical, integer, real, complex, string (or character) and raw. The modes and storage modes for the different vector types are listed in the following table.

您也可以使用矢量功能创建一个空矢量。 向量函数有两个基本参数。 第一个参数是对象的类,因此要在向量中包含的对象的类型。 第二个参数是向量本身的长度。 R具有六种基本(“原子”)向量类型:逻辑,整数,实数,复数,字符串(或字符)和原始。 下表列出了不同向量类型的模式和存储模式。

Image for post

号码 (Numbers)

Let’s come to the numbers as the most important object type. Numbers in R are generally treated as what are called numeric objectsum, so pretty much all numbers are treated as double number precision real numbers. So, even if you are looking at a number that’s like one or two, R thinks of those numbers as numeric objects there is a way to explicitly say you want an integer and you can specify the L subs, the L suf, the capital L suffix there. So for example, if you just enter the number 1 in R, that gives you a numeric object. But entering 1 with a capital L next to it explicitly gives you an integer. So, L specifies an integer type, rather than a double that the standard numeric class is.

让我们将数字作为最重要的对象类型。 R中的数字通常被视为数字对象和,因此几乎所有数字都被视为双精度数字实数。 因此,即使您正在寻找一个或两个类似的数字,R也会将这些数字视为数字对象,但是有一种方法可以明确地表示您想要一个整数,并且可以指定L个子,L suf和大写L后缀。 因此,例如,如果仅在R中输入数字1,则将为您提供数字对象。 但是,输入1并紧随其后的大写L会为您提供一个整数。 因此,L指定一个整数类型,而不是标准数字类的两倍。

> str(1)
num 1
> str(1L)
int 1

There’s a special inf, and inf is like a real number it can be used in calculations and you will get the expected result. So, for example, if you take one, divide it by zero, you’ll get infinity and if you take 1 and divide it by infinity you’ll get zero.

有一个特殊的inf,并且inf就像一个实数,可以在计算中使用,您将获得预期的结果。 因此,例如,如果乘以1,然后除以零,则将得到无穷大;如果乘以1,然后将其除以无穷,则将得到零。

nan means "not a number", a float value that you get if you perform a calculation whose result can't be expressed as a number. Any calculations you perform with NaN will also result in NaN.

nan意思是“不是数字”,这是一个浮点值,如果您执行其结果不能表示为数字的计算,则该值。 您使用NaN执行的任何计算也会产生NaN

inf means infinity. For example:

inf表示无穷大。 例如:

>>> 2*float("inf")
inf
>>> -2*float("inf")
-inf
>>> float("inf")-float("inf")
nan

属性 (Attributes)

Some of the most common types of attributes that we’ll encounter are names dimnames, dimensions, class, length, other user-defined attributes/ metadata. A dimension, so a matrix will have dimensions for example it will have a number of rows and a number of columns if you have a multidimensional array you’ll have more than two dimensions.

我们将遇到的一些最常见的属性类型是名称dimnames维,类,长度,其他用户定义的属性/元数据。 一个维度,因此矩阵将具有多个维度,例如,如果具有多维数组,它将具有多个行和多个列。

Every object have a class. So for example, numeric objects their class is numeric and integer objects, their class is integer.

每个对象都有一个。 因此,例如,数字对象的类为数字和整数对象,其类为整数。

studentBio <- list(studentName = "Tom Cruise", studentAge = 17, studentContact="New York") class(studentBio) <- "StudentInfo" studentBio$studentName
[1] "Tom Cruise"

$studentAge
[1] 19

$studentContact
[1] "New York"

attr(,"class")
[1] "StudentInfo"output:
$studentName
"Tom Cruise"

$studentAge
19

$studentContact
"New York"

attr(,"class")
"StudentInfo"

It is also necessary to know that every object has a length. Quite simply for a vector, the length of the object is the number of elements in the vector. There may also be other user-defined attributes or metadata that you can define individually for an object using various attribute functions. There is a generic function called attributes that allows you to set or change attributes() for an R object.

还必须知道每个对象都有一个长度。 对于向量来说,对象的长度就是向量中元素的数量。 您还可以使用其他属性功能为对象单独定义其他用户定义的属性或元数据。 有一个称为属性的通用函数,该函数使您可以设置或更改R对象的attribute()。

So we tried to briefly express a point on important objects and attributes. See you in the next post

因此,我们试图简要地表达关于重要对象和属性的观点。 下篇再见

翻译自: https://medium.com/swlh/data-types-r-objects-and-attributes-922427a7e0cc

本体对象属性和数据属性区别


http://www.niftyadmin.cn/n/953017.html

相关文章

气流预测网站_数据科学的数据管道第4部分气流数据管道

气流预测网站Deploy Operators and DAGs to a AWS hosted Apache Airflow and execute your Data Pipelines with DAG and Data Lineage Visualisation.将操作员和DAG部署到AWS托管的Apache Airflow&#xff0c;并通过DAG和数据沿袭可视化执行数据管道。 是否想偶尔听到有关Ten…

java 通话和重地 哈希值一样_前阿里P9的Java面试重点1:Java 语言基础

当我在群里问大家找工作有什么问题的时候&#xff0c;“找工作要看什么书&#xff1f;”“要看什么书&#xff1f;”“什么书&#xff1f;”“书……”&#xff0c;简直是自带鬼畜。萌新们啊&#xff0c;就算你们不知道赶紧做几个项目给自己的简历撑撑场面&#xff0c;但能不能…

heroku_使用heroku快速构建多租户saas启动部分1

heroku[In this multi-part series, I’ll transform a new application into a multi-tenant experience running in the Heroku ecosystem. This article focuses on the object model, design, architecture, and security.][在这个由多个部分组成的系列中&#xff0c;我将把…

python中dtype什么意思_NumPy Python中的数据类型对象(dtype)

每个ndarray都有一个关联的数据类型(dtype)对象。此数据类型对象(dtype)告知我们有关数组布局的信息。这意味着它为我们提供了有关以下信息&#xff1a; 数据类型(整数&#xff0c;浮点数&#xff0c;Python对象等) 数据大小(字节数) 数据的字节顺序(小端或大端) ndarray的值存…

华为 编程语言实验室,薪水_作为实验室科学家学习编程

华为 编程语言实验室,薪水Stop banging your head against a textbook.别再撞到教科书上了。 Four chapters into “MATLAB for Neuroscientists”, my friend asked me for advice. Her knowledge of psychology and neuroscience helped her a lot as an experimentalist, bu…

helm安装_Helm 带你飞

文章目录 [toc] 在没使用 Helm之前&#xff0c;向 K8S部署应用&#xff0c;我们要依次部署 deployment、 svc 等&#xff0c;步骤较繁琐。况且随着很多项目微服务化&#xff0c;复杂的应用在容器中部署以及管理显得较为复杂&#xff0c; Helm通过打包的方式&#xff0c;支持发布…

aws waf sql注入_您可以使用aws在纸上运行sql查询吗

aws waf sql注入Have you ever drawn some wonderful tabular data on a piece of paper and thought, “Wouldn’t it be nice if I could run an SQL query on this”?您是否曾经在纸上绘制过一些很棒的表格数据&#xff0c;并想过&#xff1a;“如果我可以对此进行SQL查询&…

枚举变量有什么用_C++自定义类型-包含不限作用域的枚举类型(学习笔记:第2章 10)...

自定义类型[1]类型别名&#xff1a;为已有类型另外命名用typedef起别名的格式&#xff1a;typedef 已有类型名 新类型名表例&#xff1a;typedef double Area, Volume; typedef int Natural; Natural i1,i2; Area a; Volume v;用using起别名的格式&#xff1a;using 新类型名 …