[R] Returning name of dataframe?

Thomas Parr thomas.parr at maine.edu
Thu Jun 20 02:16:02 CEST 2013


I am writing a function and I would like to return the name of a data frame
in a paste call, but I can't figure out how to just get the name. The names
of the data frames used, won't be the same each time.  I have to be
overlooking the obvious.

#For example:

a<-replicate(5, rnorm(20))
b<-replicate(5, rnorm(20))

xyz<-function(x,y){
  z<-x+y
  print(paste("the sum of", x, "and", y,"is", sep=" "))
  z 
}

xyz(a,b)

#That function should return:

>"the sum of a and b is:"
>.and some data.

Not surprisingly, it returns all the data in the data frame.

Thanks,
Thomas



More information about the R-help mailing list