You can write your own function, something about like this: read.table2 <- function(file, ...) { x <- read.table(file, ...) attributes(x)[["file_name"]] <- file return(x) }
mydata <- read.table2("Run224_v2_060308.txt", sep = "\t", header = TRUE) myfile <- attr(x, "file_name") On Fri, Jun 6, 2008 at 12:51 PM, DAVID ARTETA GARCIA < [EMAIL PROTECTED]> wrote: > Hi list, > > Is it possible to save the name of a filename automatically when reading it > using read.table() or some other function? > My aim is to create then an output table with the name of the original > table with a suffix like _out > > example: > > mydata = read.table("Run224_v2_060308.txt", sep = "\t", header = TRUE) > > ## store name? > > myfile = the_name_of_the_file > > ## do analysis of data and store in a data.frame "myoutput" > ## write output in tab format > > write.table(myoutput, c(myfile,"_out.txt"),sep="\t") > > the name of the new file will be > > "Run224_v2_060308_out.txt" > > Thanks in advanve, > > > > David > > ______________________________________________ > 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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
______________________________________________ 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.