Hi,
May be this helps:
dat1 <- read.table(text="FS_ID? ABNR
9327??? 33688812
11391? 33688812
11392? 33688812
11388? 33688812
11390? 33688812
12028? 33688812
12029? 33688812",sep="",header=TRUE)
dat2 <- read.table(text="FS_ID? DATE????????????? POST
11390? 2012-12-13??? 28
12029? 2013-01-17??? 28.3",header=TRUE,stringsAsFactors=FALSE)
library(reshape2)
setNames(dcast(merge(dat1,dat2,
by="FS_ID")[,-1],ABNR~DATE,value.var="POST"),c("ABNR","FIRST","SECOND"))
#????? ABNR FIRST SECOND
#1 33688812??? 28?? 28.3
A.K.
On Tuesday, February 25, 2014 4:41 AM, Mat <matthias.weber at fnt.de>
wrote:
Hello together,
i have a little problem, maybe anyone can help me.
I have 2 data.frame, one look like this one:
FS_ID? ABNR
9327? ? 33688812
11391? 33688812
11392? 33688812
11388? 33688812
11390? 33688812
12028? 33688812
12029? 33688812
the other data.frame looks like as follows:
FS_ID? DATE? ? ? ? ? ? ? POST
11390? 2012-12-13? ? 28
12029? 2013-01-17? ? 28.3
what i am looking for, is a result, which look like this one:
ABNR? ? ? ? ? FIRST? ? SECOND? ?
33688812? ? 28? ? ? ? 28.3
The ABNR and the "POST"-Value of my second data.frame should stand in
one
row. The earlier date value should stand under "FIRST", the newer date
under
"SECOND".
Maybe anyone can help me, how i can do this.
Best regards. Mat
--
View this message in context:
http://r.789695.n4.nabble.com/combine-2-data-frames-in-dependence-of-the-ID-tp4685781.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
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.