swirl 3: Sequences of Numbers
2015-08-06 18:09
393 查看
> pi:10
[1] 3.141593 4.141593 5.141593 6.141593 7.141593 8.141593 9.141593
不同于 MATLAB,a:b,a\b均可以不是整数。
> 15:1
[1] 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
可以倒着来
| Remember that if you have questions about a particular R function, you can access its documentation with a question mark followed
| by the function name: ?function_name_here. However, in the case of an operator like the colon used above, you must enclose the
| symbol in backticks like this: ?`:`
operator查询,?':'(密切注意中英文符号)
> seq(0, 10, by=0.5)
[1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0
> seq(5, 10, length=30)
[1] 5.000000 5.172414 5.344828 5.517241 5.689655 5.862069 6.034483 6.206897 6.379310 6.551724 6.724138 6.896552 7.068966
[14] 7.241379 7.413793 7.586207 7.758621 7.931034 8.103448 8.275862 8.448276 8.620690 8.793103 8.965517 9.137931 9.310345
[27] 9.482759 9.655172 9.827586 10.000000
> 1:length(my_seq)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
operator前后可以跟函数返回值
> seq(along.with = my_seq)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
seq的argument真多啊,活学活用。
> seq_along(my_seq)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
seq(along.with = my_seq) == seq_along(my_seq)
> rep(c(0, 1, 2), times = 10)
[1] 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2
rep stands for "replicate".
> rep(c(0, 1, 2), each = 10)
[1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2
rep argument 也很多啊。
[1] 3.141593 4.141593 5.141593 6.141593 7.141593 8.141593 9.141593
不同于 MATLAB,a:b,a\b均可以不是整数。
> 15:1
[1] 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
可以倒着来
| Remember that if you have questions about a particular R function, you can access its documentation with a question mark followed
| by the function name: ?function_name_here. However, in the case of an operator like the colon used above, you must enclose the
| symbol in backticks like this: ?`:`
operator查询,?':'(密切注意中英文符号)
> seq(0, 10, by=0.5)
[1] 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 7.0 7.5 8.0 8.5 9.0 9.5 10.0
> seq(5, 10, length=30)
[1] 5.000000 5.172414 5.344828 5.517241 5.689655 5.862069 6.034483 6.206897 6.379310 6.551724 6.724138 6.896552 7.068966
[14] 7.241379 7.413793 7.586207 7.758621 7.931034 8.103448 8.275862 8.448276 8.620690 8.793103 8.965517 9.137931 9.310345
[27] 9.482759 9.655172 9.827586 10.000000
> 1:length(my_seq)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
operator前后可以跟函数返回值
> seq(along.with = my_seq)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
seq的argument真多啊,活学活用。
> seq_along(my_seq)
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
seq(along.with = my_seq) == seq_along(my_seq)
> rep(c(0, 1, 2), times = 10)
[1] 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2 0 1 2
rep stands for "replicate".
> rep(c(0, 1, 2), each = 10)
[1] 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2
rep argument 也很多啊。
相关文章推荐
- UINavigationControlle(导航视图控制器)控制下的页面跳转与值的传递(协议传值)
- Can not found socket (isis issue)
- UI-xcode添加字体
- Android UI学习之Dialog
- mysql 使用 insert ignore into和unique实现不插入重复数据功能
- MUI-ActionSheet动作菜单
- java-ToStringBuilder介绍
- web前端开发常用的10个高端CSS UI开源框架
- jsp 页面显示value does not support runtime expressions
- SAPUI5 Table
- 解决UITextView 顶部空白
- UIImageView旋转动画
- 新手引导!quick
- UESTC 169 快快告诉我时间
- UESTC 170 三国
- Yahoo! UI Library 的介绍
- <Web> request 转发 && response 重定向
- UINavigationController(导航视图控制器)的基本设置
- require和include的区别
- URAL 1034. Queens in Peaceful Positions