I have two csv files.
File one has two columns:
DD1 abct
DD2 geate
DD3 watec
DD4 wwwca21
DD5 bate789
File two has one column:
abct
geate
bate789
I want to get a truncated file one to include those that matched with file two, i.e.
DD1 abct
DD2 geate
DD5 bate789
Could you mind to let me know how to do it with R?
New to R.
To merge all CSV files, use the GLOB module. The os. path. join() method is used inside the concat() to merge the CSV files together.
First, read the files with the read.table
:
file1 <- read.table("file1.csv", col.names=c("FOO", "BAR"))
file2 <- read.table("file2.csv", col.names=c("BAR"))
Then merge them:
merged <- merge(file1, file2)
And write the result:
write.table(merged, "merged.csv")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With