Re: [R] Store filename

2008-06-09 Thread jim holtman
list.files() will return the files in your current directory and you can use that in a 'for' statement to loop through processing: for (fileName in list.files()){ input <- read.table(fileName,) } On Mon, Jun 9, 2008 at 10:07 AM, DAVID ARTETA GARCIA < [EMAIL PROTECTED]> wrote: >

Re: [R] Store filename

2008-06-09 Thread DAVID ARTETA GARCIA
Hi Henrique, Daniel and Jim, and rest of the list. Your comments have been really useful. Daniel, you mention whether I am looping over some files stored in a directory. Is that actually doable with R? I mean, is it possible to read all the files in the same directory and run my script thro

Re: [R] Store filename

2008-06-07 Thread Jim Lemon
DAVID ARTETA GARCIA 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("Run

Re: [R] Store filename

2008-06-06 Thread Henrique Dallazuanna
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

Re: [R] Store filename

2008-06-06 Thread Daniel Folkinshteyn
well, where are you getting the filename in the first place? are you looping over a list of filenames that comes from somewhere? generally, for concatenating strings, look at function 'paste': write.table(myoutput, paste(myfilename,"_out.txt", sep=''),sep="\t") on 06/06/2008 11:51 AM DAVID ARTE

[R] Store filename

2008-06-06 Thread DAVID ARTETA GARCIA
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 = "\

[R] store filename

2008-06-06 Thread DAVID ARTETA GARCIA
__ 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.