博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Match function in R
阅读量:6172 次
发布时间:2019-06-21

本文共 724 字,大约阅读时间需要 2 分钟。

 

Examples:

 
    
print(match(5, c(1,2,9,5,3,6,7,4,5)))
[1] 4
 
    
5 %in% c(1,2,9,5,3,6,7,4,5)
[1] TRUE
 
    
8 %in% c(1,2,9,5,3,6,7,4,5)
[1] FALSE
 
> v1 <- c("a1","b2","c1","d2")
> v2 <- c("g1","x2","d2","e2","f1","a1","c2","b2","a2")
> x <- match(v1,v2)
> x
[1] 6 8 NA 3
 
    
> v1 <- c("a1","b2","c1","d2")
> v2 <- c("g1","x2","d2","e2","f1","a1","c2","b2","a2")
> v1 %in% v2
[1] TRUE TRUE FALSE TRUE
 
    
> v1 <- c("a1","b2","c1","d2")
> v2 <- c("g1","x2","d2","e2","f1","a1","c2","b2","a2")
> x <- match(v1,v2, nomatch = 0)
> x
[1] 6 8 0 3
 
    
> v1 <- c("a1","b2","c1","d2")
> v2 <- c("g1","x2","d2","e2","f1","a1","c2","b2","a2")
> x <- match(v1,v2, nomatch = 0, incomparables = "a1")
> x
[1] 0 8 0 3

 

ref:

https://www.r-bloggers.com/match-function-in-r/

 

转载地址:http://uytba.baihongyu.com/

你可能感兴趣的文章
Android JNI入门第三篇——jni头文件分析
查看>>
ubuntu server 10.4下NFS服务的配置
查看>>
nginx+php-FastCGI+mysql性能测试
查看>>
Openstack架构及基本概念理解
查看>>
默认路由
查看>>
CYQ.Data 轻量数据层之路 框架开源系列 索引
查看>>
zabbix(2)使用自带模板完成基本监控
查看>>
安装rrdtool出现的错误
查看>>
木马隐藏地点全搜查
查看>>
Subversion版本控制
查看>>
奇怪的打印纸盘故障
查看>>
hyperledger v1.0.5 区块链运维入门(一)
查看>>
Mybatis-mapper-xml-基础
查看>>
5. GC 调优(基础篇) - GC参考手册
查看>>
Windows 7 XP 模式颜色质量只有16位的解决
查看>>
SonicWall如何安全模式升级防火墙
查看>>
Linux IPC实践(3) --具名FIFO
查看>>
从Atlas到Microsoft ASP.NET AJAX(6) - Networking, Application Services
查看>>
成长之路---写好一个类
查看>>
读取 java.nio.ByteBuffer 中的字符串(String) 写入方式flash.utils.ByteArray.writeUTF
查看>>