首先,对不起标题.我试图找到一个合适的标题.我的问题"是我有一个向量,比如说 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 中另一个向量的递增部分
发布评论