Is there a way to rename a data frame using the value of a string?
I'm trying to write a function in [R] that takes a vector of values, operates over them, and (among other things) returns a data frame to the global environment using the <<- operator. I'd like the name of this data frame to reflect the name of the vector used to create it.
Ideally the code would look something like this:
my.func <- function(vector.in){ # ... Operations over vector.in ... # data.out <- data.frame(x1 = ...) new.name <- paste("data.out", deparse(substitute(vector.in)), sep="_") #Change the name of data.out to the value of the string new.name changename(data.out, new.name) #Export the newly named object to the global environment new.name <<- new.name # ... More operations ... # }
changenamefunction,?changenamedoesn't return anything for me.