hello together,
i have a task No. in a data.frame
Task_No Team
A 49397 1
B 49396 1
and now i want to match my Person-IDs to each Task_No. My Person Ids look
like this one:
ID Team
A 5019 1
B 472 1
C 140 1
D 5013 1
The solution should be this:
Task_No Team ID
A 49397 1 5019
A 49397 1 472
A 49397 1 140
A 49397 1 5013
B 49396 1 5019
B 49396 1 472
B 49396 1 140
B 49396 1 5013
perhabs anyone can help me.
Thank you
Mat
--
View this message in context: http://r.789695.n4.nabble.com/match-a-task-No-to-a-few-person-IDs-tp4658646.html
Sent from the R help mailing list archive at Nabble.com.
match a task No. to a few person-IDs
4 messages · Mat, arun, PIKAL Petr +1 more
Hi, Try this: dat1<- read.table(text=" ????? Task_No????? Team?? A??? 49397??????? 1???????? B??? 49396??????? 1 ",sep="",header=TRUE) dat2<- read.table(text=" ??? ID??????? Team A 5019??? 1 B 472??? 1 C 140??? 1 D 5013??? 1 ",sep="",header=TRUE) ?res1<- as.matrix(merge(dat1,dat2,by="Team")) ?row.names(res1)<-LETTERS[match(res1[,2],dat1[,1])]? library(plyr) res2<- as.matrix(join(dat1,dat2,by="Team")) ?row.names(res2)<-LETTERS[match(res2[,1],dat1[,1])] ?res2 #? Task_No Team?? ID #A?? 49397??? 1 5019 #A?? 49397??? 1? 472 #A?? 49397??? 1? 140 #A?? 49397??? 1 5013 #B?? 49396??? 1 5019 #B?? 49396??? 1? 472 #B?? 49396??? 1? 140 #B?? 49396??? 1 5013 A.K. ----- Original Message ----- From: Mat <matthias.weber at fnt.de> To: r-help at r-project.org Cc: Sent: Friday, February 15, 2013 4:45 AM Subject: [R] match a task No. to a few person-IDs hello together, i have a task No. in a data.frame ? ? ? Task_No? ? ? Team? ? A? ? 49397??? ? ? 1??? ? ? ? B? ? 49396??? ? ? 1? ??? and now i want to match my Person-IDs to each Task_No. My Person Ids look like this one: ? ? ID? ? ? ? Team A 5019??? 1 B 472??? 1 C 140??? 1 D 5013??? 1 The solution should be this: ? ? ? Task_No? ? ? Team? ? ID A? ? 49397??? ? ? 1??? ? ? ? ? ? 5019 A? ? 49397??? ? ? 1??? ? ? ? ? ? 472 A? ? 49397??? ? ? 1??? ? ? ? ? ? 140 A? ? 49397??? ? ? 1??? ? ? ? ? ? 5013 B? ? 49396??? ? ? 1? ??? ? 5019 B? ? 49396??? ? ? 1? ? ? ? ? ? 472 B? ? 49396??? ? ? 1? ? ? ? ? ? 140 B? ? 49396??? ? ? 1? ? ? ? ? ? 5013 perhabs anyone can help me. Thank you Mat -- View this message in context: http://r.789695.n4.nabble.com/match-a-task-No-to-a-few-person-IDs-tp4658646.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.
Hi ?merge Regards Petr
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
project.org] On Behalf Of Mat
Sent: Friday, February 15, 2013 10:45 AM
To: r-help at r-project.org
Subject: [R] match a task No. to a few person-IDs
hello together,
i have a task No. in a data.frame
Task_No Team
A 49397 1
B 49396 1
and now i want to match my Person-IDs to each Task_No. My Person Ids
look like this one:
ID Team
A 5019 1
B 472 1
C 140 1
D 5013 1
The solution should be this:
Task_No Team ID
A 49397 1 5019
A 49397 1 472
A 49397 1 140
A 49397 1 5013
B 49396 1 5019
B 49396 1 472
B 49396 1 140
B 49396 1 5013
perhabs anyone can help me.
Thank you
Mat
--
View this message in context: http://r.789695.n4.nabble.com/match-a-
task-No-to-a-few-person-IDs-tp4658646.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.
Hello,
Use ?merge.
tasks <- read.table(text = "
Task_No Team
A 49397 1
B 49396 1
", header = TRUE)
ids <- read.table(text = "
ID Team
A 5019 1
B 472 1
C 140 1
D 5013 1
", header = TRUE)
merge(tasks, ids, all.x = TRUE)
Hope this helps,
Rui Barradas
Em 15-02-2013 09:45, Mat escreveu:
hello together,
i have a task No. in a data.frame
Task_No Team
A 49397 1
B 49396 1
and now i want to match my Person-IDs to each Task_No. My Person Ids look
like this one:
ID Team
A 5019 1
B 472 1
C 140 1
D 5013 1
The solution should be this:
Task_No Team ID
A 49397 1 5019
A 49397 1 472
A 49397 1 140
A 49397 1 5013
B 49396 1 5019
B 49396 1 472
B 49396 1 140
B 49396 1 5013
perhabs anyone can help me.
Thank you
Mat
--
View this message in context: http://r.789695.n4.nabble.com/match-a-task-No-to-a-few-person-IDs-tp4658646.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.