Re: [R] failed when merging two dataframes, why

2009-04-09 Thread Jun Shen
I would suggest use the same column names for the common columns. Say, use "codetot" for both df1 and df2. Then you don't even have to specify by.x or by.y, merge will do it automatically. merge(df1,df2, all=TRUE). Otherwise you have to merge(df1,df2,by.x=c('popcode','codetot'),by.y=c('popcode','c

Re: [R] failed when merging two dataframes, why

2009-04-09 Thread jim holtman
try this: > merge(df1, df2, by.x='codetot',by.y='codetoto', all=TRUE) codetot popcode.x p3need popcode.y areasec 1 BCPy01-01-1 BCPy01-01 100. BCPy01-01 0.5089434 2 BCPy01-01-2 BCPy01-01 100. BCPy01-01 0.6246381 3 BCPy01-01-3 BCPy01-01 100. BCPy01-01 0.4370059 4 BCPy01-02

[R] failed when merging two dataframes, why

2009-04-09 Thread Mao Jianfeng
Hi, R-listers, Failed, when I tried to merge df1 and df2 by "codetot" in df1 and "codetoto" in df2. I want to know the reason and how to merge them together. Data frames and codes I have used were listed as followed. Thanks a lot in advance. df1: popcode codetot p3need BCPy01-01 BCPy01-01-1