生成一个序列,它是 R 中另一个向量的递增部分

编程入门 行业动态 更新时间:2024-10-28 08:19:13
本文介绍了生成一个序列,它是 R 中另一个向量的递增部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

首先,对不起标题.我试图找到一个合适的标题.我的问题"是我有一个向量,比如说 1-5,我想从中创建一个新的向量.哪去了1, 1,2 , 1,2,3, 1,2,3,4, 1,2,3,4,5

First of all, sorry for the title. i tried to find an appropriate title. My "problem" is that I have a vector, say 1-5 from which I would like to make a new vector. Which goes 1, 1,2 , 1,2,3, 1,2,3,4, 1,2,3,4,5

因此,对于每一轮,从基线向量开始包含一个新数字,直到它到达终点.我有一种感觉应该可以使用 seq ...

So for each round in includes one new number from the baseline vector until it reaches the end. I have a feeling it should be possible with seq...

推荐答案

参见 ?sequence(来自手册页):

See ?sequence (from the manpage):

对于 nvec 的每个元素,都会创建序列 seq_len(nvec[i]).将这些连接起来并返回结果.

For each element of nvec the sequence seq_len(nvec[i]) is created. These are concatenated and the result returned.

示例:

sequence(1:5) [1] 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5

更多推荐

生成一个序列,它是 R 中另一个向量的递增部分

本文发布于:2023-11-29 00:05:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1644496.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:向量   它是   序列

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!