Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-15 Thread Kevin Wamae
illiam Dunlap Date: Saturday, 14 October 2017 at 20:21 To: Kevin Wamae Cc: Bert Gunter , Rui Barradas , R-help Subject: Re: [R] Populate one data frame with values from another dataframe for rows that match Your example used one distinct studyno in DF1 and one distinct pf_mcl in DF2. I thin

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-15 Thread Kevin Wamae
Rui Barradas , R-help Subject: Re: [R] Populate one data frame with values from another dataframe for rows that match Your example used one distinct studyno in DF1 and one distinct pf_mcl in DF2. I think that makes it hard to see what is going on, but maybe I completely misunderstand the prob

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-14 Thread William Dunlap via R-help
e way you want. ifelse() may be useful for that. Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Oct 13, 2017 at 10:48 PM, Kevin Wamae wrote: > Dear @Bert Gunter<mailto:bgunter.4...@gmail.com>, I tried merge and I > faced many challenges. @Rui Barradas<mailto:ruipbarra...@sapo.pt

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-14 Thread Kevin Wamae
, 14 October 2017 at 12:43 To: Kevin Wamae Cc: Rui Barradas , "r-help@r-project.org" Subject: Re: [R] Populate one data frame with values from another dataframe for rows that match Hi Kevin, I think there are issues with Rui's proposed solution. For example, if there are rows in

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-14 Thread Eric Berger
Hi Kevin, I think there are issues with Rui's proposed solution. For example, if there are rows in myDF1 which have a studyno which does not match any row in myDF2, then you will lose those rows. In your original request you said that you wanted to keep those rows. To demonstrate my point I need t

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-13 Thread Kevin Wamae
Dear @Rui Barradas, thank you for the solution. It works perfectly. On 13/10/2017, 23:35, "Rui Barradas" wrote: Hello, Try the following. myDF1$studyno <- as.character(myDF1$studyno) myDF2$studyno <- as.character(myDF2$studyno) i1 <- which(names(myDF1) == "pf_

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-13 Thread Kevin Wamae
Dear @Bert Gunter<mailto:bgunter.4...@gmail.com>, I tried merge and I faced many challenges. @Rui Barradas<mailto:ruipbarra...@sapo.pt> solution is working. From: Bert Gunter Date: Friday, 13 October 2017 at 22:44 To: Kevin Wamae Cc: R-help Subject: Re: [R] Populate one data frame

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-13 Thread Rui Barradas
Hello, Try the following. myDF1$studyno <- as.character(myDF1$studyno) myDF2$studyno <- as.character(myDF2$studyno) i1 <- which(names(myDF1) == "pf_mcl") merge(myDF1[-i1], myDF2, by = "studyno") Hope this helps, Rui Barradas Em 13-10-2017 20:09, Kevin Wamae escreveu: I'm trying to populat

Re: [R] Populate one data frame with values from another dataframe for rows that match

2017-10-13 Thread Bert Gunter
?merge Bert On Oct 13, 2017 12:09 PM, "Kevin Wamae" wrote: > I'm trying to populate the column “pf_mcl” in myDF1 with values from > myDF2, where rows match based on column "studyno" but the solutions I have > found so far don't seem to be giving me the desired output. > > Below is a snapshot of

[R] Populate one data frame with values from another dataframe for rows that match

2017-10-13 Thread Kevin Wamae
I'm trying to populate the column “pf_mcl” in myDF1 with values from myDF2, where rows match based on column "studyno" but the solutions I have found so far don't seem to be giving me the desired output. Below is a snapshot of the data.frames. myDF1 <- structure(list(studyno = c("J1000/9", "J10