Hi,
dat1<- read.table(text="
V1??? V2
A????? 1
B????? 2
C????? 1
D????? 3
",sep="",header=TRUE,stringsAsFactors=FALSE)
dat2<- read.table(text="
V3??????? V2
AAA?????? 1
BBB?????? 2
CCC?????? 3
",sep="",header=TRUE,stringsAsFactors=FALSE)
library(plyr)
join(dat1,dat2,by="V2",type="full")
#? V1 V2? V3
#1? A? 1 AAA
#2? B? 2 BBB
#3? C? 1 AAA
#4? D? 3 CCC
merge(dat1,dat2)
#? V2 V1? V3
#1? 1? A AAA
#2? 1? C AAA
#3? 2? B BBB
#4? 3? D CCC
A.K.
>Dear R-users,
>
>I have the following 2 files;
>
>A
>
>V1 ? ?V2
>A ? ? ?1
>B ? ? ?2
>C ? ? ?1
>D ? ? ?3
>
>B
>
>V1 ? ? ? ? V2
>AAA ? ? ? 1
>BBB ? ? ? 2
>CCC ? ? ? 3
>
>
>I want to get this output
>
>C
>V1 ? ?V2 ? ? V3
>A ? ? ?1 ? ? ? AAA
>B ? ? ?2 ? ? ? BBB
>C ? ? ?1 ? ? ? AAA
>D ? ? ?3 ? ? ? CCC
>
>I want to compare A$V2 with B$V2, if it is the same, then append B$V1 to A.
>
>How to.... ??
>
>Please