当前位置:网站首页>R语言:文本(字符串)处理与正则表达式
R语言:文本(字符串)处理与正则表达式
2022-07-31 11:12:00 【Mrrunsen】
处理文本是每一种计算机语言都应该具备的功能,但不是每一种语言都侧重于处理文本。R语言是统计的语言,处理文本不是它的强项,perl语言这方面的功能比R不知要强多少倍。幸运的是R语言的可扩展能力很强,DNA/RNA/AA等生物序列现在已经可以使用R来处理。
nchar 字符的个数
toupper 转换为大写字符
tolower 转换为小写字符
substr 求字符串的字串
grep 基于正则表达式的匹配
sub 基于正则表达式的替换
strsplit 字符串分割
paste 字符向量连接
match 匹配元素位置组成的向量
R语言处理文本的能力虽然不强,但适当用用还是可以大幅提高工作效率的,而且有些文本操作还不得不用。高效处理文本少不了正则表达式(regular expression),虽然R在这方面先天不高效,但它处理字符串的绝大多数函数都使用正则表达式。
0、正则表达式简介:
正则表达式不是R的专属内容,所以用0编号,这里也只简单介绍,更详细的内容请查阅其他文章。
正则表达式是用于描述/匹配一个文本集合的表达式。
所有英文字母、数字和很多可显示的字符本身就是正则表达式,用于匹配它们自己。比如 ‘a’ 就是匹配字母 ‘a’ 的正则表达式
一些特殊的字符在正则表达式中不在用来描述它自身,它们在正则表达式中已经被“转义”,这些字符称为“元字符”。
perl类型的正则表达式中被转义的字符有:. \ | ( ) [ ] { } ^ $ * + ?。被转义的字符已经有特殊的意义,如点号 . 表示任意字符;
方括号表示选择方括号中的任意一个(如[a-z] 表示任意一个小写字符ÿ
边栏推荐
- 生命不息,刷题不止,简单题学习知识点
- Deletion of the sequence table
- 《MySQL高级篇》五、InnoDB数据存储结构
- After class, watching the documentation and walking back to the lab, I picked up the forgotten SQL operators again
- strings包详细文档+示例
- Implement the popup component
- The principle of v-model
- Single sign-on principle and implementation
- 面试、工作中常用sql大全(建议收藏备用)
- Detailed tutorial on distributed transaction Seata
猜你喜欢

ApiPost is really fragrant and powerful, it's time to throw away Postman and Swagger

“带薪划水”偷刷阿里老哥的面经宝典,三次挑战字节,终成正果

"JUC Concurrent Programming - Advanced" 06 - Immutability of Shared Models (Design of Immutable Classes | Use of Immutable Classes | Flyweight Pattern)

一文带你了解redux的工作流程——actionreducerstore

《云原生的本手、妙手和俗手》——2022全国新高考I卷作文

【JWT】JWT 整合

In half a month, MySQL has been consolidated again, and a tens of thousands of words "super hard core" article has been sorted out!

拥抱趋势!阿里这套微服务开源框架权威手册,实战到底层细致清晰

突破传统可靠性测试:混沌工程优秀实践

《MySQL高级篇》四、索引的存储结构
随机推荐
SQLServer2019 installation (Windows)
apisix-Getting Started
Windows系统Mysql8版本的安装教程
Single sign-on principle and implementation
502 bad gateway原因、解决方法
SQL力扣刷题五
Implement the popup component
【软件工程之美 - 专栏笔记】33 | 测试工具:为什么不应该通过QQ/微信/邮件报Bug?
Insertion and deletion of doubly linked list
Windows安装mysql详细步骤(通俗易懂,简单上手)
apisix-入门使用篇
7 天能找到 Go 工作吗?学学 Go 数组和指针试试
《MySQL高级篇》五、InnoDB数据存储结构
Sql optimization summary!detailed!(Required for the latest interview in 2021)
If the value of the enum map does not exist, deserialization is not performed
IBM SPSS Statistics 28软件安装包下载及安装教程
分布式事务——分布式事务简介、分布式事务框架 Seata(AT模式、Tcc模式、Tcc Vs AT)、分布式事务—MQ
sql力扣刷题六
redis-enterprise use
[ 图 论 ]二分图判定及其匹配(基础+提高)