数据集1
location
Bhilai, C.G
Delhi
Dadar, Mumbai
Bangalore, India
数据集2
location state
Bhilai C.G
Delhi Delhi
Dadar Maharastra
Bangalore Karnataka
我想要一个像这样的输出
输出
location state
Bhilai, C.G C.G
Delhi Delhi
Dadar, Mumbai Maharashtra
Bangalore, India Karnatak
一
使用过的代码:
> loc$key = 1
> location2$key = 1
> newdataset <- merge(loc, location2, by="key")
> newdataset <- newdataset[newdataset$location.y %in% newdataset$location.x,
c("location.x", "state")]
输出:
[1] location.x state.y
<0 rows> (or 0-length row.names)