Get name of dataframe passed through pipe in R : <p>I would like to be able to print the name of a dataframe passed through the pipe. Is this possible? I can do.</p>

<pre><code>printname &lt;- function(df){
    print(paste(substitute(df)))
}
printname(mtcars)
#[1] "mtcars"
</code></pre>

<p>However, it returns "." when this function is piped using the <code>magrittr</code> pipe.</p>

<pre><code>mtcars %&gt;% printname
# [1] "."
</code></pre>

<p>This would be helpful when writing custom error messages of functions used in logged production processes -- it's hard to know where something failed if the only thing in the log is "." </p>

<p>It would probably be enough to return the original call, which would include the <code>mtcars %&gt;%</code> piece.</p>
