使用StringDist_join与不同的列名称
我的示例数据如下:
library(fuzzyjoin)
a <- data.frame(x = c("season", "season", "season", "package", "package"), y = c("1","2", "3", "1","6"))
b <- data.frame(x = c("season", "seson", "seson", "package", "pakkage"), w = c("1","2", "3", "2","6"))
c <- data.frame(z = c("season", "seson", "seson", "package", "pakkage"), w = c("1","2", "3", "2","6"))
因此,以下运行良好:
d <- stringdist_left_join(a,b, by = "x", max_dist = 2)
但是不允许使用带有不同名称的列合并(请注意,联接是a
and c
) 。
e <- stringdist_left_join(a,c, by = c("x", "z"), max_dist = 2)
我想告诉stringdist_left_join
使用两个不同的列名来加入,例如代码的最后一行(e)
,但似乎不接受它。
是否有任何解决方案(除了复制列并给它另一个名称)吗?
I have example data as follows:
library(fuzzyjoin)
a <- data.frame(x = c("season", "season", "season", "package", "package"), y = c("1","2", "3", "1","6"))
b <- data.frame(x = c("season", "seson", "seson", "package", "pakkage"), w = c("1","2", "3", "2","6"))
c <- data.frame(z = c("season", "seson", "seson", "package", "pakkage"), w = c("1","2", "3", "2","6"))
So the following runs fine:
d <- stringdist_left_join(a,b, by = "x", max_dist = 2)
But merging with a column with a different name is not allowed (note that the join is now a
and c
).
e <- stringdist_left_join(a,c, by = c("x", "z"), max_dist = 2)
I would like to tell stringdist_left_join
to use two different column names to join by, like the last line of code it (e)
, but it does not seems to accept it.
Is there any solution to this (other than copying the column and giving it another name)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
=
用于两个不同的列名。您可以使用以下代码:输出:
You can use
=
for two different column names. You can use the following code:Output: