Tag Archives: deparse

Obtaining R Object name


While programming in R, occasionally I wish I can just get the name of an object that I am working with and print out the name, or use the name as a name for the current plot that I am creating.

This is more convenient when creating a function that your user might not have an idea yet what the title should be. By default, the title name in most plot functions in R is created using “deparse(substitute(x))” function

mydata <- cbind(c(1:10),c(1:10))
plot(mydata,main=deparse(substitute(mydata)))
deparse(substitute(mydata))
Name the plot after the name of the data frame used to create this plot.
Advertisements