-1

I have two csv files, which share some common columns. Is there a way to get the intersection, union and asymmetric difference of these two files? For both of these two files, the first row are text characters and the other rows are just 0 or 1.

The csv files are like

A.csv

abc rec

0 0

1 0

0 1

B.csv

alt rec

1 0

1 0

0 1

Community
  • 1
  • 1
bit-question
  • 3,733
  • 17
  • 50
  • 63
  • This is very, very similar to the [question you asked 20 minutes ago](http://stackoverflow.com/q/12324942/271616). Could you show what you've tried and how the solution to your prior question is not applicable? – Joshua Ulrich Sep 07 '12 at 21:04
  • Actually, he did mention in the accepted answer to the prevails question that he had an extended question. The last was about vectors, I guess this is about data frames. – Alex Brown Sep 07 '12 at 21:07
  • Do you want the union based on the first row column names? or positional? Can you post a portion of each file? What have you already tried? Do you read them into R or can you use a [command line tool](http://stackoverflow.com/questions/2509533/bash-linux-set-difference-between-two-text-files)? – Justin Sep 07 '12 at 21:12
  • the union/intersection are all based on the first row.I know that some unix commands can do this? I am also curious that whether r provides similar functionality? A portion of each data file has been added into my original question. – bit-question Sep 07 '12 at 21:21
  • so, if the ones and zeros are irrelevant... `a=read.csv('A.csv'); b=read.csv('B.csv'); setdiff(names(A), names(B))`. Just like your previous question. – Justin Sep 07 '12 at 21:53

1 Answers1

0

This is answered in an earlier question: How to do intersect, union, etc. on ordered pairs?

There really no reason it needs to be restricted to pairs. You can have any number of vector be pasted together to form an index. In a very real sense I have converted your second question into the first one.

Community
  • 1
  • 1
IRTFM
  • 258,963
  • 21
  • 364
  • 487