rspotfirerscriptterr

Comparison between two Data Sets using R Scripting / TERR in Spotfire


I want to compare the two data table columns ID using R-Script / TERR in spotfire. Due to some limitations in am not able to install the functions called "compare","SQLDf". I can use the functions called "duplicated". Can some one help me in creating the sample script with out using the above functions.

Please find the below images for the detailed requirements.

Two Data Table

Result Table

Thanks, -Vidya


Solution

  • Let's say you have two vectors setA and setB. You can get the result by

    # in A but not in B
    setdiff(setA,setB)
    # in B but not in A
    setdiff(setB,setA)
    # both in A and B
    intersect(setA,setB)
    

    If you just want to know the count use the length function. This may not be the exact answer you were looking for but using the above functions you can create any set you want. If you need help with a specific logic please update your question.