title: Pass variable name to a function in r
body: <p>Is it possible to pass just a variable name in a function call and have it utilised as such within the function??</p>
  
  <p>pseudocode:</p>
  
  <pre><code>q&lt;-function(A){
      b&lt;-(w%in%A.2|w%in%A.7)  
      factor(b,levels=c(F,T),labels=c("non-"A,A))}
  
  
  w&lt;-c(0:10)
  e.2&lt;-c(1,2)
  e.7&lt;-c(6,7)
  </code></pre>
  
  <p>what I´d like to do is </p>
  
  <pre><code>q(e)
  </code></pre>
  
  <p>and have returned </p>
  
  <p>non-e,e,e,non-e,non-e,e,e,non-e,non-e</p>
  
  <p>//M</p>
  
  <hr>
  
  <pre><code>q&lt;-function(A) {
      a2&lt;-get(paste(a,".2",sep=""))
      a7&lt;-get(paste(a,".7",sep=""))
      b&lt;-(w%in%a2|%in%a7) 
      factor(b,levels=c(F,T),labels=c(paste("non-",a,sep=""),a)) 
  }
  
  q("e")
  </code></pre>
  
  <p>Thx, </p>
  
  <p>M</p>