title: R error: 'match' requires vector arguments - package function with S4 object (raster) as parameter, and operator %in%
body: <p>My goal is simply to use the %in% operator to compare the values in a raster object with the values I have in a vector.</p>
  
  <p>This works fine, straight from the console:</p>
  
  <pre><code>values(raster(rbind(c(2,6,7,8),c(4,5,6,7),c(3,4,7,5),c(1,23,1,6))) %in% c(2,5,7))
  
   [1]  TRUE FALSE  TRUE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE  TRUE  TRUE FALSE FALSE FALSE FALSE
  </code></pre>
  
  <p>However I need a function inside a package I'm developing, and I have the following code: </p>
  
  <pre><code>test_lst &lt;- function( rst) {
      return ( rst %in% c( 2, 5, 7))
  }
  </code></pre>
  
  <p>When I load the package and call the function: </p>
  
  <pre><code>devtools::load_all( ".")
  test_lst( raster( rbind( c( 2, 6, 7, 8),
                           c( 4, 5, 6, 7),
                           c( 3, 4, 7, 5),
                           c( 1, 23,1, 6))))
  </code></pre>
  
  <p>What I get is the following error:</p>
  
  <pre><code>Error in match(x, table, nomatch = 0L) : 
  'match' requires vector arguments
  </code></pre>
  
  <p>I can't see what I'm doing wrong. 'raster' is declared in the imports section of the description file.</p>