You don't have to name them after numbers. What I sent was just an example of a character vector with file names. If you have all the files in a directory, then you can set the loop to read in all the files (or selected one based on a pattern match). If you are copy/pasting the 'scan' command, then you must somehow be changing the file name that is being read and the R object that you are storing the values in.
You can use list.files(pattern="..") to select a list of file names. This is much easier than copy/paste. On 8/8/07, Tiandao Li <[EMAIL PROTECTED]> wrote: > I thought of loop at first. My data were generated from 32 microarray > experiments, each had 3 replicates, 96 files in total. I named the files > based on different conditions or time series, and I really won't want to > name them after numbers. It will make me confused later when I need to > refer/compare them. > > > On Tue, 7 Aug 2007, jim holtman wrote: > > I would hope that you don't have 100 'scan' statements; you should > just have a loop that is using a set of file names in a vector to read > the data. Are you reading the data into separate objects? If so, > have you considered reading the 100 files into a 'list' so that you > have a single object with all of your data? This is then easy to save > with the 'save' function and then you can quickly retrieve it with the > 'load' statement. > > file.names <- c('file1', ..., 'file100') > input.list <- list() > for (i in file.names){ > input.list[[i]] <- scan(i, what=....) > } > > You can then 'save(input.list, file='save.Rdata')'. You can access > the data from the individual files with: > > input.list[['file33']] > > > > > > On 8/7/07, Tiandao Li <[EMAIL PROTECTED]> wrote: > > In the first part of myfile.R, I used scan() 100 times to read data from > > 100 different tab-delimited files. I want to save this part to another > > data file, so I won't accidently make mistakes, and I want to re-use/input > > it like infile statement in SAS or \input(file.tex} in latex. Don't want > > to copy/paste 100 scan() every time I need to read the same data. > > > > Thanks! > > > > On Tue, 7 Aug 2007, jim holtman wrote: > > > > If you are going to read it back into R, then use 'save'; if it is > > input to another applicaiton, consider 'write.csv'. I assume that > > when you say "save all my data files" you really mean "save all my R > > objects". > > > > On 8/7/07, Tiandao Li <[EMAIL PROTECTED]> wrote: > > > Hello, > > > > > > I am new to R. I used scan() to read data from tab-delimited files. I want > > > to save all my data files (multiple scan()) in another file, and use it > > > like infile statement in SAS or \input{tex.file} in latex. > > > > > > Thanks! > > > > > > ______________________________________________ > > > R-help@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 > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > -- > > Jim Holtman > > Cincinnati, OH > > +1 513 646 9390 > > > > What is the problem you are trying to solve? > > > > > -- > Jim Holtman > Cincinnati, OH > +1 513 646 9390 > > What is the problem you are trying to solve? > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? ______________________________________________ R-help@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 and provide commented, minimal, self-contained, reproducible code.