title: R: How to pass an object to a function?
body: <p>I'm newbie in R and I'm trying to pass an object to a function but I've got an error when I try to access to a slot of this object.</p>
  
  <p>These are my main code:</p>
  
  <pre><code>x &lt;- new("menu", competition=0, stats=0, query="")
  y &lt;- show(x)
  show_graphics(y)
  </code></pre>
  
  <p>After second instruction I've got the object "y" created correctly like you can see in this screencap:</p>
  
  <p><a href="https://i.stack.imgur.com/Z6BWV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z6BWV.png" alt="enter image description here"></a></p>
  
  <p>Then, I call to a the function "show_graphics" and pass this object "y" like a parameter. But when I try to access to an slot in the first insctruction of my function:</p>
  
  <pre><code>show_graphics &lt;- function(menu){
    data &lt;- getData(menu@query)
    ......
  }
  </code></pre>
  
  <blockquote>
    <p>I've got an error that tell me that there is an error to try to access
    to the slot "query" of an object to the basic class "function" without
    slots.</p>
  </blockquote>
  
  <p>How can I pass correctly an object to a function? Or how can I get the values from an object passed to a function?</p>
  
  <p>Am I doing something wrong?</p>
  
  <p><strong>Edit I:</strong></p>
  
  <p>This is the code to create the object "menu":</p>
  
  <pre><code>setClass("menu", slots=list(competition="numeric", stats="numeric", query="character"))
  show &lt;- function(object) 0
  setGeneric("show")
  setMethod("show", "menu", function(object){
    object@competition &lt;- 14
    object@stats &lt;- 1
    object@query &lt;- "query"
    return (object)
  })
  </code></pre>
  
  <p><strong>Edit II:</strong></p>
  
  <p>getData is another function, here is the code of a prototype:</p>
  
  <pre><code>getData &lt;- function(query){
     return (query)
  }
  </code></pre>