title: R Error: Problem with `mutate()` input `type`. x `f` must be a factor (or character vector)
body: <p>I'm having trouble with these errors in R... I don't know how to fix it.</p>
  <p>Error: Problem with <code>mutate()</code> input <code>type</code>.
  x <code>f</code> must be a factor (or character vector).
  i Input <code>type</code> is <code>fct_relevel(type, c(&quot;hit&quot;, &quot;bad-hit [evalue &gt; 0.01]&quot;, &quot;non-hit&quot;))</code>.</p>
  <p>I'm pretty sure the code worked before with a different data set, but now it's generating these errors...</p>
  <p>#Script to get to where I'm at (you may need to install biostrings)</p>
  <pre><code>BiocManager::install(&quot;Biostrings&quot;)
  </code></pre>
  <ul>
  <li></li>
  </ul>
  <pre><code>library(tidyverse) 
  library(data.table)
  
    a &lt;- 
                    &quot;qseqid      sseqid  pident       length mismatch gapopen qstart qend  sstart    send   ppos evalue bitscore
                    KQJ81400 NC_012870.2 100.000        10        0       0     1354 1383  49691442  49691471 100.00   0.33   25.3
                    KQJ81513 NC_012871.2 100.000        11        0       0     1288 1256  77518889  77518857 100.00   0.00   30.4&quot;
      
      blasts &lt;- read.table(text=a, header = TRUE)
       
  
  
  BrachCDS &lt;- Biostrings::readDNAStringSet('ftp://ftp.ensemblgenomes.org/pub/plants/release-47/fasta/brachypodium_distachyon/cds/Brachypodium_distachyon.Brachypodium_distachyon_v3.0.cds.all.fa.gz') %&gt;% as.data.frame() %&gt;% rownames_to_column(var='gene') %&gt;% 
  rename(seq=x) %&gt;% as_tibble()
      
   c &lt;-
  
      &quot;&gt;KQJ81400 cds chromosome:Brachypodium_distachyon_v3.0:5:440113:447844:-1 gene:BRADI_5g00478v3 gene_biotype:protein_coding 
      &gt;KQJ81513 cds chromosome:Brachypodium_distachyon_v3.0:5:1105857:1107846:-1 gene:BRADI_5g01198v3 description:hypothetical protein&quot;
      
      B1000 &lt;-fread(c, header = F, fill= T, select =c(1,2))
  
  
  
  blasts &lt;- blasts %&gt;% arrange(qseqid,-pident,evalue,-bitscore) %&gt;%
  distinct (qseqid, .keep_all = T) %&gt;%
  mutate(evalue=round(evalue,digits = 2)) %&gt;%
  rename(subject_length=length) 
  </code></pre>
  <p>(I actually have my own CDS file which is in multiline fasta format with just the qseqid so I don't think that's the problem)</p>
  <p>And then this is the part of the script I get an error with:</p>
  <pre><code>B1000_SEQ &lt;- BrachCDS %&gt;% filter(gene %in% B1000$V1) %&gt;%
  mutate(length=nchar(seq)) %&gt;%
  left_join(blasts, by=c('gene'='qseqid')) %&gt;%
             mutate(type=ifelse(is.na(evalue),'non-hit',
                     ifelse(evalue &lt;= 0.01,'hit','bad-hit [evalue &gt; 0.01]')),
                               type=fct_relevel(type,c('hit','bad-hit [evalue &gt; 0.01]','non-hit')))
  </code></pre>
  <p>What does it mean by 'f'? Where even is 'f' and why isn't it a factor? And what's going on with 'type'?
  Any help into what's going on or how to fix it would be greatly appreciated!</p>
  <p>EDIT: Solved it, see comments... my bad</p>