tags:

views:

101

answers:

1

I have tried the merge function to merge two csv files that I imported. They both have the same variable names and data types but each time I run merge all that I get is an object that contains the names of the two data frames. I have tried the following:

# ex1
obj <- merge(obj1, obj2, by=obj)
# ex2
obj <- merge(obj1, obj2, all)

and several other iterations of the above.

Is merge the correct function? If so, what am I doing wrong?

+9  A: 

I am guessing that you actually want to rbind the data.frames, rather than merging them?

Try:

obj <- rbind(obj1, obj2)

merge() is really used to do the equivalent of a JOIN in SQL.

Shane
Right, and to expand on that, if df1 and df2 share the same column names, merge(df1, df2) will actually return just those rows that are identical between the two dfs! Which is definitely not what you wanted, OP!
Harlan