Demo entry 6770188

r

   

Submitted by anonymous on Nov 12, 2018 at 09:18
Language: S. Code size: 1.1 kB.

专利数据匹配代码
zlzl=function(x,y,z)  #用于数据匹配的函数
{
chuli=read.csv(x)  #读取待匹配数据
gsm=read.csv(y)
gsm$gsm=as.character(gsm$gsm)  #对读入文件的字段进行格式转换
chuli$flh=as.character(chuli$flh)  
chuli$rq=as.character(chuli$rq)
chuli$sqr=as.character(chuli$sqr)

flh=rep("a",dim(chuli)[1]) #生成新的数据表所需要的字段
rq=flh
sqr=rq
rx=data.frame(flh=as.character(flh),rq=as.character(flh),sqr=as.character(flh)) #将字段整合为新的数据表
rx$flh=as.character(rx$flh)
rx$rq=rx$flh
rx$sqr=rx$flh
k=1
for(i in 1:dim(chuli)[1])  #运用双重循环对发明专利数据进行匹配
{
	for(j in 1:length(gsm$gsm))
	{
		if(grepl(gsm$gsm[j],chuli$sqr[i]))  #本段代码核心,找出含有上市公司的专利条目
		{
			rx$sqr[k]=gsm$gsm[j] #把上市公司名称,专利的法律状态写入新的数据表
			rx$rq[k]=chuli$rq[i]
			rx$flh[k]=chuli$flh[i]
			k=k+1
				
		}
	}

}
rnsz=rx[rx$rq!="a",]  #去除新数据表没有内容的部分
write.csv(rnsz,z)





}
system.time(zlzl("fzn06.csv","gsm.csv","fzr06.csv"))  #执行代码
system.time(zlzl("fzn05.csv","gsm.csv","fzr05.csv"))
system.time(zlzl("fzn03.csv","gsm.csv","fzr03.csv"))
system.time(zlzl("fzn02.csv","gsm.csv","fzr02.csv"))
system.time(zlzl("fsn02.csv","gsm.csv","fsr02.csv"))
system.time(zlzl("szn03.csv","gsm.csv","szr03.csv"))

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).