I have two data frames,
df1
Identifier GSE1028888 GSE1034555
100002 0.1 0.2
100003 0.3 0.4
...... ..... .....
100007 0.9 1.1
df2
V3 V2
100002 XLX12
100003 ABorF
...... .....
110000 GEF22
Now I want insert the V2 information into df1, such as
df3
Identifier New_V2 GSE1028888 GSE1034555
100002 XLX12 0.1 0.2
100003 ABorF 0.3 0.4
100004 NA 0.6 0.7
...... ..... .....
100007 ccL34 0.9 1.1
The V3 of df2 and Identifier of df1 have different length. I try dplyr left_join, but the column is attached at the end.
This is the code to create similar data frame
df1 <- data.frame("Identifier" = sample(100001:100010, 6, replace = F),
y = sample(rnorm(10), 6, replace = T),
z = sample(rnorm(10), 6, replace = T))
df2 <- data.frame(V1 = c(100001:100010),
V2 = sample(state.name, 10, replace = T))
This time when I try dplyr left_join,
left_join(df1, df2, by =c("Identifier"="V3"))
an error message was shown
Error: cannot join on columns 'V3' x 'Identifier': index out of bounds
Anyone has any idea?
dput()
) or use one of the example data sets in R. Also, add the minimal code required to reproduce your problem to your post. – Stibu