Of course the second this showed up on R-help, I got rid of the formal argument 'mydata' and just used ..., which seems to have solved the problem.
Erik Erik Iverson wrote: > Hello - > > I would like to create a wrapper to the 'save' function in the base > package, but have a small problem with the name of the object that is > getting saved in the file. Below is a simple example illustrating my > problem. > > ## BEGIN SAMPLE R CODE > > ################################################## > ## Here is the wrapper for the save function > ################################################## > > wrapsave <- function(mydata, ...) { > save(mydata, ...) > } > > ################################################## > ## Create a test data.frame and save it > ################################################## > > testdf <- data.frame(a = rnorm(10), b = rnorm(10)) > wrapsave(testdf, file = "~/test.Rdata") > > ################################################## > ## remove test data.frame and try to load it > ################################################## > > rm(testdf) > load(file = "~/test.Rdata") > > ## END SAMPLE R CODE > > After the load function is called, an object called 'testdf' does not > exist in the global environment, but an object called 'mydata' does. I > understand why, but I'd like 'wrapsave' to save the object passed to it > with the name of the object it was called with, in this case 'testdf'. > Is this possible? > > Thank you, > Erik Iverson > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.