Skip to content
Prev 278995 / 398502 Next

Writing a function, want a string argument to define the name of the excel sheet to be called

Sure, change your example as follows and then you can pass the name properly:

foo <- function(x,y,NAME = "filename.csv"){

#make a matrix with x rows and y cols
M <- matrix(nrow=x,ncol=y)
#write the matrix
write.table(M, file = NAME,append=TRUE, sep = ",") 
}

Bryan
****************
Prof. Bryan Hanson
Dept of Chemistry & Biochemistry
DePauw University
Greencastle IN 46135 USA
academic.depauw.edu/~hanson/deadpezsociety.html
github.com/bryanhanson
academic.depauw.edu/~hanson/UMP/Index.html
On Dec 1, 2011, at 8:43 AM, AOLeary wrote: