title: Call objects in function wrapped around ggplot2-function
body: <p>I am about to write a function to iterate my plots over various variables. Unfortunately I am getting an error i don't understand. </p>
  
  <pre><code>library(ggplot2)
  library(dplyr)
  library(purrr)
  
  df &lt;- data.frame(af = c(rep(1,6),rep(2,6),rep(3,6)), 
  p = c(rep(c(rep("A",2),rep("B",2),rep("C",2)),3)), 
  ele.1 = sample(c(1:100), size=6), 
  ele.2 = sample(c(1:100), size=6), 
  ele.3 = sample(c(1:100), size=6))
  
  
  af p ele.1 ele.2 ele.3
  1 A    99     1    68
  1 A    55    38    72
  1 B    70    36    13
  1 B    86    77    89
  1 C     7    24    49
  1 C    89    23    53
  2 A    99     1    68
  2 A    55    38    72
  ....
  
  test &lt;- function(.x = df, .af = 1,.p=c("A","B"), .var = ele.1) {.x %&gt;%
          filter(af == .af &amp; p %in% .p) %&gt;%
          ggplot(aes(x = .var, y = ele.2)) +
          geom_point() +
          geom_path()}
  
  
  test(df)
  </code></pre>
  
  <p>this results in</p>
  
  <pre><code>**Error in FUN(X[[i]], ...) : object 'ele.1' not found
  In addition: Warning message:
  In FUN(X[[i]], ...) : restarting interrupted promise evaluation**
  </code></pre>
  
  <p>how could i call the object ele.1 in ggplot warped around that function?</p>
  
  <p>hope this is no reword from another question. </p>
  
  <p>cheers</p>