Guest User

Untitled

a guest
Jan 16th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. Locus S1 S2 S3
  2. loc1 87 56 77
  3. loc2 34 55 75
  4. loc3 12 09 78
  5. loc4 34 67 89
  6. loc5 78 65 46
  7.  
  8. Locus S1 S2 S3
  9. loc3 13 43 34
  10. loc5 43 56 90
  11. loc7 89 56 33
  12. loc1 56 88 00
  13. loc4 66 77 98
  14. loc2 34 44 66
  15.  
  16. Locus S1 S2 S3
  17. loc1 56 88 00
  18. loc2 34 44 66
  19. loc3 13 43 34
  20. loc4 66 77 98
  21. loc5 43 56 90
  22.  
  23. file1 <-read.delim(file="file1.txt",header=TRUE,sep="t")
  24. file2 <-read.delim(file="file2.txt",header=TRUE,sep="t")
  25. new_output <- file1[file1$Locus %in% file2$Locus,]
  26. write.table(new_output,file="new_output.txt",sep="t")
  27.  
  28. merge(file1["Locus"], file2, by = "Locus")
  29.  
  30. # Locus S1 S2 S3
  31. #1 loc1 56 88 0
  32. #2 loc2 34 44 66
  33. #3 loc3 13 43 34
  34. #4 loc4 66 77 98
  35. #5 loc5 43 56 90
  36.  
  37. new_output <- file2[match(file1$Locus, file2$Locus), ]
  38.  
  39. file1 <-read.delim(file = "file1.txt", header = TRUE, sep = "t", row.names = 1)
  40. file2 <-read.delim(file = "file2.txt", header = TRUE, sep = "t", row.names = 1)
  41. new_output <- file2[rownames(file1$Locus), ]
Add Comment
Please, Sign In to add comment