How do I pair values from two differently long columns in R? -


i have 2 data frames in format similar this:

     name1 1    retta mclennon 2      deloras wurm 3    tristan partee 4   lashonda swayne 5 christiane bendel 

and

    name2 1  christiane bendel 2     tristan partee 3       ronni sugrue 4    lashonda swayne 5       alvaro fahey 6   tamie kalinowski 7   jefferson levitt 8     retta mclennon 9        haywood neu 10      deloras wurm 

i create new column in name1 in value "yes" ascribed rows contained in name2.

            > df1                            name             1    retta mclennon             2      deloras wurm             3    tristan partee             4   lashonda swayne             5 christiane bendel            > df2                             name             1  christiane bendel             2     tristan partee             3       ronni sugrue             4    lashonda swayne             5       alvaro fahey             6   tamie kalinowski             7   jefferson levitt             8     retta mclennon             9        haywood neu             10      deloras wurm       colnames(df1)[2] <- "match"     df1$match <- data.frame(ifelse(df1$name %in% df2$name , "yes", "no"))  > df1                name                                     match 1    retta mclennon                                      yes 2      deloras wurm                                      yes 3    tristan partee                                      yes 4   lashonda swayne                                      yes 5 christiane bendel                                      yes 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

android - CoordinatorLayout, FAB and container layout conflict -