R语言字母向量
2015-10-25 06:27
281 查看
R中的常量包含以下几种
seq()函数
生成数字向量常用的函数,可定义生成向量的最大最小值,from = min, to = max;用 by = ***可定义步长,默认为1。length.out定义向量所包含的数字个数。
想要生成字符向量,先生成数字,然后把数字转化为字母
R语言中向量是从1开始
> e[1]
给e向量添加元素
获取e中某几个元素
获取e中连续的几个元素
LETTERS: the 26 upper-case letters of the Roman alphabet;
letters: the 26 lower-case letters of the Roman alphabet;
month.abb: the three-letter abbreviations for the English month names;
month.name: the English names for the months of the year;
pi: the ratio of the circumference of a circle to its diameter.
seq()函数
生成数字向量常用的函数,可定义生成向量的最大最小值,from = min, to = max;用 by = ***可定义步长,默认为1。length.out定义向量所包含的数字个数。
想要生成字符向量,先生成数字,然后把数字转化为字母
> e <- LETTERS[seq(1,26)] > e [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z"
R语言中向量是从1开始
> e[1]
[1] "A"
给e向量添加元素
> e[27] <- "AA" > e [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" [20] "T" "U" "V" "W" "X" "Y" "Z" "AA"
获取e中某几个元素
> e[c(5,8,13)] [1] "E" "H" "M"
获取e中连续的几个元素
> e[5:16] [1] "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P"
相关文章推荐
- Leetcode: Unique Paths
- Python代码的多线程改造
- 下一代云计算模式:Docker正掀起个性化商业革命
- layout_gravity和gravity的区别
- 从微软到灵雀云:一个理工男的“云上云”之路
- Isomorphic Strings - LeetCode
- Word Pattern - LeetCode
- 遗传基因科普(7):探索DNA奥秘不该忘却的一位女性
- Spring MVC 4.2.2 中最好的集成静态资源的方法
- [LeetCode 295] Find Median from Data Stream
- R语言产生随机数
- C++ string 换行显示
- perl中模块的编写和使用举例
- 动态规划 triangle
- git rebase无法处理的问题
- Container_of详解
- Visual Studio 2015 keyboard shortcuts
- git整理纷乱的历史合并记录
- i2c_mux
- 常用软件下载