表1:testcode
表2:test1圖片
把表1的樓盤匹配到表2不規則的樓盤裏面。string
library(stringr) #導入表2的數據 totaldata<-read.table("C:/Users/steph/Desktop/visual/test1.csv",sep=",",header=FALSE) total<-as.matrix(totaldata) data1<-as.vector(total) #導入表1的數據 seconddata<-read.table("C:/Users/steph/Desktop/visual/test.csv",sep=",",header=FALSE) second<-as.matrix(seconddata) data2<-as.vector(second) b<-length(data2) #循環替換 for(n in 1:b){ i<-data2[n] data1[which(str_detect(data1,i)==TRUE)]<-i next } #導出到本地 setwd("C:/Users/steph/Desktop/visual") write.table(data1,"mydata.csv",sep=",")