Question: I have a function that looks like this:

```
removeRows <- function(dataframe, rows.remove){
  dataframe <- dataframe[-rows.remove,]
  print(paste("The", paste0(rows.remove, "th"), "row was removed from", "xxxxxxx"))
}

```

I can use the function like this to remove the 5th row from the dataframe:

```
removeRows(mtcars, 5)

```

The function output this message:

```
"The 5th row was removed from xxxxxxx"

```

How can I replace xxxxxxx with the name of the dataframe I have used, so in this case `mtcars`?

Answer: 
You need to access the variable name in an unevaluated context. We can use [`substitute`](http://stat.ethz.ch/R-manual/R-devel/library/base/html/substitute.html) for this:

```
removeRows <- function(dataframe, rows.remove) {
  df.name <- deparse(substitute(dataframe))
  dataframe <- dataframe[rows.remove,]
  print(paste("The", paste0(rows.remove, "th"), "row was removed from", df.name))
}

```

In fact, that is its main use; as per the documentation,

> 
> The typical use of `substitute` is to create informative labels for data sets and plots.
> 
> 
>
I would like to point out that `df.name <- deparse(substitute(dataframe))` should be used **at the top of your function** before any transformation is done. I used it right at the end of my function, just before doing ggsave, which does not return the name but somehow what is inside the dataframe, which is not what you want. This gave me a lot of headache.

So something like this :

```
function(df){
df.name <- deparse(substitute(dataframe))
ggplot()
ggsave()
}

```