[R] Matching data in two files but returning a value from a adjacent column

arun smartpink111 at yahoo.com
Thu Jan 23 18:12:54 CET 2014


Hi,
Try ?merge() or ?join() from library(plyr)
#Please provide reproducible example.

 set.seed(42)
 dat1 <- data.frame(Stat_Ana=sample(20:30,10,replace=TRUE))
dat2 <- data.frame(Stat_Ana=20:30,Group=LETTERS[1:11])

merge(dat1,dat2,by="Stat_Ana")
library(plyr)
 join(dat1,dat2,by="Stat_Ana")
A.K.


I have a dataset where I have a column which holds information on what geographical statistical analysis square that row of data is from. 
Groups of these statistical squares make up management regions. 
In my second file I simply have a column of all statistical squares 
and adjacent to this a column of which management region this stat 
square is in. I want to find a way of using the stat squares in file one
 to look into file two, find the corresponding stat square but then 
return the management area value to an empty column in file one. Can 
anyone help me? 




More information about the R-help mailing list