R序列seq

> seq(from=10,to=20,by=3)

[1] 10 13 16 19

> seq(from=10,to=20,length=5)

[1] 10.0 12.5 15.0 17.5 20.0

 

## Default S3 method:

seq(from = 1, to = 1, by = ((to - from)/(length.out - 1)),

    length.out = NULL, along.with = NULL, ...)

 

seq.int(from, to, by, length.out, along.with, ...)

 

seq_along(along.with)  从这个参数的长度取长度

seq_len(length.out)  序列所需长度

 

> data.frame(a=seq_along(mtcars$mpg),b=mtcars$mpg,c=seq(along.with= mtcars$mpg))

a     b      c
1   21.0  1
2   21.0  2
3   22.8  3
4   21.4  4
5   18.7  5
6   18.1  6
7   14.3  7
8   24.4  8
9   22.8  9
10 19.2 10
11 17.8 11
12 16.4 12
13 17.3 13
14 15.2 14
15 10.4 15
16 10.4 16
17 14.7 17
18 32.4 18
19 30.4 19
20 33.9 20
21 21.5 21
22 15.5 22
23 15.2 23
24 13.3 24
25 19.2 25
26 27.3 26
27 26.0 27
28 30.4 28
29 15.8 29
30 19.7 30
31 15.0 31
32 21.4 32

posted @ 2016-11-21 22:38  智能先行者  阅读(585)  评论(0编辑  收藏  举报