r语言中删除向量的某些元素_R中的向量

r语言中删除向量的某些元素

Vectors in R are the fundamental data types. This is because the R compiler treats all scalars (numerics, integers, etc.) and matrices as special cases of vectors.

R中的向量是基本数据类型。 这是因为R编译器将所有标量(数字,整数等)和矩阵都视为向量的特殊情况。

From a data scientist’s perspective, you can consider a vector as a collection of observations across an interval of time, such as temperatures read every day, total sales for the day, etc. R provides several relevant functions to handle vectors from this perspective.

从数据科学家的角度来看,您可以将向量视为一段时间内观察值的集合,例如每天读取的温度,一天的总销售额等。R从此角度提供了一些相关函数来处理向量。

在R中创建向量 (Creating Vectors in R)

The creation of a vector is done using the c() function.

向量的创建是使用c()函数完成的。


myvec <- c(3.1,45,1,2,80)

R language provides us the functionality to dynamically calculate values and assign them to vectors.

R语言为我们提供了动态计算值并将其分配给向量的功能。


> myvec2 <- c(3,5*8,(9/4))
> myvec2
[1]  3.00 40.00  2.25

We can create vectors using previously created variables.

我们可以使用先前创建的变量创建矢量。


> a <- 10
> b <-14.8
> c <-2
> myvec3 <- c(1,a,b,c)
> myvec3
[1]  1.0 10.0 14.8  2.0

We can also create a vector using two or more of the existing vectors.

我们还可以使用两个或多个现有向量创建向量。


  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值