title: Error in UseMethod("mutate_") : no applicable method for 'mutate_' applied to an object of class "function"
body: <p>I am trying to run a loop that will compile Bureau of Labor Statistics employment data from 2002 to 2010 in one large data frame for multiple Metro Statistical Areas.</p>
  
  <p>When I run the loop, I get the following error and I am not sure why this is occurring. Anyone have any ideas?</p>
  
  <pre><code>Error in UseMethod("mutate_") : 
    no applicable method for 'mutate_' applied to an object of class "function"
  </code></pre>
  
  <p>Here is my full code for this small project.</p>
  
  <pre><code>library(tidyverse)
  library(blscrapeR)
  
  msa &lt;- read.delim("https://raw.githubusercontent.com/smitty1788/Personal-Website/master/dl/MSA_Codes.txt",
                  header = FALSE) %&gt;% 
    rename(area_code = V2, area_text = V3) %&gt;% 
    select(area_code, area_text) %&gt;% 
    mutate(CBSA_ID = substr(area_code, 5, 9))
  
  MSA_LAUS &lt;- data.frame(date = character(),
                         labor_force = numeric(),
                         employment = numeric(),
                         unemployment = numeric(),
                         unemployment_rate = numeric(),
                         CBSA_ID = character(),
                         area_text = character())
  
  for (i in 1:395) {
  
    labor_force &lt;- paste0("LAU", msa$area_code[i], "06")
    employment &lt;- paste0("LAU", msa$area_code[i], "05")
    unemployment &lt;- paste0("LAU", msa$area_code[i], "04")
    unemployment_rate &lt;- paste0("LAU", msa$area_code[i], "03")
  
    series_id &lt;- tibble(
      name = c("labor_force", "employment", "unemployment", "unemployment_rate"),
      id = c(labor_force, employment, unemployment, unemployment_rate)
    )
  
  
    laus &lt;- bls_api(seriesid = c(labor_force, employment, unemployment, unemployment_rate), 
                    startyear = 2002, endyear = 2010, 
                    registrationKey = **"YOUR BLS API KEY"**) %&gt;%
      mutate(seriesID = as.character(seriesID)) %&gt;% 
      merge(series_id, by.x = 'seriesID', by.y = 'id', all.x = TRUE) %&gt;%
      filter(!is.na(name)) %&gt;% 
      select(year, periodName, name, value) %&gt;% 
      spread(name, value = value) %&gt;% 
      mutate(date = as.Date(paste0(year, " ", periodName, " ", "01"), '%Y %B %d'),
             CBSA_ID = msa$CBSA_ID[i],
             area_text = msa$area_text[i]) %&gt;% 
      select(date, labor_force, employment, unemployment, unemployment_rate, CBSA_ID, area_text)
  
    MSA_LAUS &lt;- rbind(MSA_LAUS, laus)
    rm(laus)
  }
  </code></pre>