Skip to content
Prev 309107 / 398506 Next

Delete row if two values in a matrix are equal

Hello,

First, two notes:
1. 'var' is a really bad name for a variable, it already is an R function.
2. Your matrix seems more like a data.frame. The difference is important 
because data.frames by default coerce character strings to factors. I 
have tried to make the code work if this is the case or not.


vr <- read.table(text="
Ref_Pos Ref_Allele Var_Allele Var_Freq
      1             A                  A                 100
      2                    T                  G                  50
      3                    G                  G                 100
      4                    G                  T                  45
      5                     T                  C                  80
", header = TRUE)

yes <- as.character(vr[, "Ref_Allele"]) != as.character(vr[, "Var_Allele"])
vr[yes, ]



Hope this helps,

Rui Barradas

Em 26-10-2012 15:26, JDINIS escreveu: