为什么R中的矢量指数1开始,而不是0? [英] Why do vector indices in R start with 1, instead of 0?

查看:404
本文介绍了为什么R中的矢量指数1开始,而不是0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是什么,而不是通常<$ C $的原因,在研究矢量指数与 1 开始, C> 0 ?

What is the reason that vector indices in R start with 1, instead of the usual 0?

例如:

> arr<-c(10,20)
> arr[0]
numeric(0)
> arr[1]
[1] 10
> arr[2]
[1] 20

难道只是他们想存储有关矢量额外的信息,不知道在哪里把它除了存储为载体的第一要素?

Is it just that they want to store extra information about the vector and didn't know where to store it except as the vector's first element?

推荐答案

FORTRAN是从1开始的数学家阵列处理的载体,它始终与组件1开始,经过N.直线代数约定开始行和列的一种语言编号为1,进入到第N个为好。

FORTRAN is one language that starts arrays at 1. Mathematicians deal with vectors that always start with component 1 and go through N. Linear algebra conventions start with row and column numbered 1 and go through N as well.

下开始以零,因为指针运算,这是隐含的下面。 Java中的JavaScript,C ++和C#也跟着从C。

C started with zero because of the pointer arithmetic that was implicit underneath. Java, JavaScript, C++, and C# followed suit from C.

这篇关于为什么R中的矢量指数1开始,而不是0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆