[R] paste argument of a function as a file name

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Thu Nov 10 14:50:31 CET 2005


my.write <- function( obj, name ){

  filename <- file=paste( name, ".txt", sep="")
  write.table( obj, file=filename, sep="\t", quote=F)

}

my.write( df, "output" )

Regards, Adai


On Thu, 2005-11-10 at 13:28 +0000, Luis Ridao Cruz wrote:
> R-help,
> 
> I have a function which is exporting the output to a file via
> write.table(df, file =  "file name.xls" )
> 
> What I want is to paste the file name (above) by taking the argument to
> the function as a file name 
> 
> something like this:
> 
> MY.function<- function(df)
> {
> ...
> ...
> write.table(df,"argument.xls")
> }
> MY.function(argument)
> 
> 
> Thank you
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list