-1

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

VidyaSagar
  • 11
  • 4
  • Pictures? Have some consideration. Learn to post reproducible questions that do not require us to be your data entry slave. Have some consideration for your audience. Make it easy to construct a test case and a validated answer. – IRTFM Oct 15 '16 at 06:36
  • Thanks for your comments. Next time I will keep this in my mind. – VidyaSagar Oct 20 '16 at 20:40

1 Answers1

1

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.

Rohit Das
  • 1,962
  • 3
  • 14
  • 23
  • This worked like a charm. This is what I am looking for. Actually I am new to R. I really appreciate your help here. – VidyaSagar Oct 20 '16 at 20:39
  • Hi, When I am trying to the run the below code I am getting the following error. – VidyaSagar Oct 24 '16 at 16:40
  • Hi, When I am trying to the run the below code I am getting the following error setA <- c(1,3,9) setB <- c(2,3,4,5,6,7) removedfromsetA <- setdiff(setA,setB) addedtosetB <- setdiff(setB,setA) commoncolumns <- intersect(setA,setB) Comparions <- data.frame(removedfromsetA,addedtosetB) – VidyaSagar Oct 24 '16 at 16:40
  • Error in data.frame(removedfromsetA, addedtosetB) : arguments imply differing number of rows: 2, 5 – VidyaSagar Oct 24 '16 at 16:42