[R] Merging two dataframes

From: Michael Pearmain <mpearmain_at_google.com>
Date: Fri, 06 Jun 2008 12:30:25 +0100


Hi All,

Newbie question for you all but i have been looking at the archieves and the help dtuff to get a rough idea of what i want to do

I would like to merge two dataframes together based on a keyed variable in one dataframe linking to the other dataframe. Only some of the cases will match but i would like to keep the others as well.

My dataframes have 67 and 28 cases respectively and i would like ot end uip with one file 67 cases long (all 28 are matched cases).

I can use the merge command to merge two datasets together this but i still get some
odd results, i'm using the code below;

ETC <- read.csv(file="CSV_Data2.csv",head=TRUE,sep=",")
'SURVEY <- read.csv(file="survey.csv",head=TRUE,sep=",")
'FullData <- merge(ETC, SURVEY, by.SURVEY = "uid", by.ETC = "ord")

The merged file seems to have 1800 cases while the ETC data file only has 67 and the SURVEY file only has 28. (Reading the help it looks as if it merges 1 case with all cases in the other file, which is not what i want)

The matching variables fields are the 'ord' field and the 'uid' field Can anyone advise please?

-- 
Michael Pearmain

	[[alternative HTML version deleted]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 06 Jun 2008 - 14:08:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 06 Jun 2008 - 14:30:39 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive