来自dplyr包的连接在新列中产生NA结果

当我生成以下给定数据帧的left_join(来自包dplyr的left_join)时,结果(即)连接后的新列往往是NA。

列'V1','V1_1','V1_2','V1_3'分别是来自数据帧“df1”和“df2”的因子。 通过将它们转换为字符后警告消息被移除了之前发生的事件。

警告信息:

在left_join_impl(x,y,by $ x,by $ y,后缀$ x,后缀$ y)中:加入字符向量和因子,强制转换为字符向量

然而,在删除警告和清理代码后,新连接后的列会生成NA。 我无法纠正发生了什么问题。 任何形式的帮助表示赞赏。

DF1

  V1    V2
A415Z   1.01
A415J   0.91
B416X   0.95
B416Z   0.97
B416J   1.03
B416M   1.16
B416P  11.75
B416W   0.98
D420R   0.98
D420H   0.94
D420Z   1.01
D420J   1.01
D420F   0.90
D420L   1.00
C462H   0.93
C462P   0.83
C462W   0.73

DF2

 V1_1  V1_2  V1_3
A415Z B416P D420R
A415Z B416P D420H
A415Z B416P D420Z
A415Z B416P D420J
A415Z B416P D420F
A415Z B416P D420L
A415Z B416P C462H
A415Z B416P C462P
A415Z B416P C462W
A415J B416P D420R
A415J B416P D420H
A415J B416P D420Z
A415J B416P D420J
A415J B416P D420F
A415J B416P D420L
A415J B416P C462H
A415J B416P C462P
A415J B416P C462W
B416P D420R C462H
B416P D420R C462P
B416P D420R C462W
B416P D420H C462H
B416P D420H C462P
B416P D420H C462W
B416P D420Z C462H
B416P D420Z C462P
B416P D420Z C462W
B416P D420J C462H
B416P D420J C462P
B416P D420J C462W
B416P D420F C462H
B416P D420F C462P
B416P D420F C462W
B416P D420L C462H
B416P D420L C462P
B416P D420L C462W

码:

库(dplyr)

newdf <-left_join(DF2,DF1,通过= C( “V1_1”= “V1”))

产量

   V1_1  V1_2  V1_3 V2
  A415Z B416P D420R NA
  A415Z B416P D420H NA
  A415Z B416P D420Z NA
  A415Z B416P D420J NA
  A415Z B416P D420F NA
  A415Z B416P D420L NA
  A415Z B416P C462H NA
  A415Z B416P C462P NA
  A415Z B416P C462W NA
  A415J B416P D420R NA
  A415J B416P D420H NA
  A415J B416P D420Z NA
  A415J B416P D420J NA
  A415J B416P D420F NA
  A415J B416P D420L NA
  A415J B416P C462H NA
  A415J B416P C462P NA
  A415J B416P C462W NA
  B416P D420R C462H NA
  B416P D420R C462P NA
  B416P D420R C462W NA
  B416P D420H C462H NA
  B416P D420H C462P NA
  B416P D420H C462W NA
  B416P D420Z C462H NA
  B416P D420Z C462P NA
  B416P D420Z C462W NA
  B416P D420J C462H NA
  B416P D420J C462P NA
  B416P D420J C462W NA
  B416P D420F C462H NA
  B416P D420F C462P NA
  B416P D420F C462W NA
  B416P D420L C462H NA
  B416P D420L C462P NA
  B416P D420L C462W NA

期望的输出应该包含来自与“df2”相邻的“df1”值的列V2。

链接地址: http://www.djcxy.com/p/30937.html

上一篇: join from dplyr package produces NA results in the new column

下一篇: Controlling alpha in ggparcoord (from GGally package)