title: R: dplyr can't filter() certain character
body: <p>The data (named "metInfo") I use is provided here (<a href="https://drive.google.com/file/d/1sGtOBOzD-K4iEpDUyeb9e5b_D7afr7Fk/view?usp=sharing" rel="nofollow noreferrer">https://drive.google.com/file/d/1sGtOBOzD-K4iEpDUyeb9e5b_D7afr7Fk/view?usp=sharing</a>)</p>
  
  <p>As you can see, in the <code>metInfo %&gt;% pull(rtc) %&gt;% unique</code> has two levels</p>
  
  <pre><code>&gt; library(dplyr)
  &gt; load("metInfo.RData")
  &gt; metInfo %&gt;% pull(rtc) %&gt;% unique
  [1] RTC  nRTC
  Levels: nRTC RTC
  </code></pre>
  
  <p>And the strange part is that I can <code>metInfo %&gt;% filter(rtc == "RTC")</code> but not <code>metInfo %&gt;% filter(rtc == "nRTC")</code>.
  "RTC"</p>
  
  <pre><code>&gt; metInfo %&gt;% filter(rtc == "RTC")
  # A tibble: 318 x 3
  # Groups:   Compound_Name [318]
     peak_ID   rtc   Compound_Name                                     
     &lt;chr&gt;     &lt;fct&gt; &lt;chr&gt;                                             
   1 PP_012966 RTC   Uric acid                                         
   2 PP_010664 RTC   Norleucine                                       
   3 PP_011736 RTC   L-Tryptophan                                     
   4 PP_012298 RTC   O-Acetyl-L-carnitine                             
   5 PP_010311 RTC   Betaine | 5-Aminopentanoic acid                   
   6 PP_012958 RTC   L-Tyrosine | 3-Amino-3-(4-hydroxyphenyl)propanoate
   7 PP_011703 RTC   L-Leucine | L-Isoleucine                         
   8 PP_010688 RTC   Cycloleucine | (S)-Piperidine-2-carboxylic acid   
   9 PN_006454 RTC   Glycochenodeoxycholic acid                       
  10 PP_011268 RTC   L-Histidine                                       
  # ... with 308 more rows
  </code></pre>
  
  <p>"nRTC"</p>
  
  <pre><code>&gt; metInfo %&gt;% filter(rtc == "nRTC")
  # A tibble: 0 x 3
  # Groups:   Compound_Name [0]
  # ... with 3 variables: peak_ID &lt;chr&gt;, rtc &lt;fct&gt;, Compound_Name &lt;chr&gt;
  </code></pre>
  
  <p>However, using R base filtering function, it returns what I want:</p>
  
  <pre><code>&gt; metInfo[metInfo$rtc == "nRTC",]
  # A tibble: 344 x 3
  # Groups:   Compound_Name [344]
     peak_ID   rtc   Compound_Name                                                                                                                               
     &lt;chr&gt;     &lt;fct&gt; &lt;chr&gt;                                                                                                                                       
   1 PP_011268 nRTC  L-Histidine                                                                                                                                 
   2 PP_011695 nRTC  L-Kynurenine                                                                                                                               
   3 PN_008846 nRTC  Decanedioic acid                                                                                                                           
   4 PP_011647 nRTC  L-Glutamic acid                                                                                                                             
   5 PN_005920 nRTC  Azelaic acid                                                                                                                               
   6 PP_010311 nRTC  Betaine | 5-Aminopentanoic acid                                                                                                             
   7 PN_001048 nRTC  [(3aS,4S,5S,6E,10E,11aR)-6-formyl-5-methoxy-10-methyl-3-methylidene-2-oxo-3a,4,5,8,9,11a-hexahydrocyclodeca[b]furan-4-yl] 2-methylpropanoate
   8 PP_010704 nRTC  Pyroglutamic acid                                                                                                                           
   9 PN_007538 nRTC  Octanedioic acid                                                                                                                           
  10 PP_012958 nRTC  L-Tyrosine | 3-Amino-3-(4-hydroxyphenyl)propanoate                                                                                         
  # ... with 334 more rows
  </code></pre>
  
  <p>Strange enough, I tried to create a data.frame to see if this is due to <code>"n"</code> problem such as <code>"\n"</code> for something, but it turns out that this is not the case:
  No problem with "nRTC"</p>
  
  <pre><code>haha &lt;- data.frame(a =c("A", "B", "C", "D", "E", "F"), b = c("RTC", "RTC", "RTC", "nRTC", "nRTC", "nRTC")) %&gt;% as.tbl()
  &gt; haha %&gt;% filter(b == "nRTC")
  # A tibble: 3 x 2
    a     b   
    &lt;fct&gt; &lt;fct&gt;
  1 D     nRTC
  2 E     nRTC
  3 F     nRTC
  </code></pre>
  
  <p>Nor "RTC"</p>
  
  <pre><code>&gt; haha %&gt;% filter(b == "RTC")
  # A tibble: 3 x 2
    a     b   
    &lt;fct&gt; &lt;fct&gt;
  1 A     RTC 
  2 B     RTC 
  3 C     RTC 
  </code></pre>
  
  <p>Nor "nRTC" with R base</p>
  
  <pre><code>&gt; haha[haha$b == "nRTC", ]
  # A tibble: 3 x 2
    a     b   
    &lt;fct&gt; &lt;fct&gt;
  1 D     nRTC
  2 E     nRTC
  3 F     nRTC
  </code></pre>
  
  <p>This is the structure of <code>metInfo$rtc</code></p>
  
  <pre><code>&gt; dput(metInfo$rtc)
  structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 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