更改向量的元素 [英] Change elements of a vector

查看:26
本文介绍了更改向量的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含数千个元素的向量.如果我想让索引在 100-200 之间的元素变为 0,需要什么 R 代码?

Say I have a vector which has thousands of elements. What is the R code necessary if I want to make the elements at indices between 100-200 become 0?

另外,我将如何计算两个不同值之间的长度,例如,如果我想知道股价"在 30-40 之间的时间长度?

Additionally how would I count the length between two different values, for example if I want to know the length of time when the 'share price' is between 30-40?

推荐答案

请阅读安装随附的R 简介"手册.

Please read the 'Introduction to R' manual that came with your installation.

你的一个问题很简单

  X[ 100:200 ] <- 0

其他操作类似.这是必不可少的材料,所以你需要多读一点.

and the other operations are similar. This is essential material, so you need to read up a little.

这篇关于更改向量的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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