Dear all,
I'm new to this list, so let me greet everyone.
My problem is that I have several thousand data files which I want to
perform a lot of R commands on, which are found in a seperate .R script.
Now, what I did was within the R prompt, I used to read in a list of the
data files.
e.g.
namelist <- readLines("list_of_names",n=-1)
for (i in 1:100) {
k <- function(namelist[i])
write(k,file="outputfile",append=TRUE)
}
Next, I tried automating the R commands by making a loop. Within the
loop I called the R-script. Within ecery single loop R called the R-script
and performs the commands therein (or is supposed to perform it) on
the actual data file.
After a loop finished, I tried appending the output to an output file.
The problem is that R gives an error message saying that it cannot
open the input files.
What can I do?
Thanks, Matthew
Cserh?ti M?ty?s wrote:> > Dear all, > > I'm new to this list, so let me greet everyone. > > My problem is that I have several thousand data files which I want to > perform a lot of R commands on, which are found in a seperate .R script. > > Now, what I did was within the R prompt, I used to read in a list of the > data files. > > e.g. > > namelist <- readLines("list_of_names",n=-1) > for (i in 1:100) { > k <- function(namelist[i]) > write(k,file="outputfile",append=TRUE) > } > > Next, I tried automating the R commands by making a loop. Within the > loop I called the R-script. Within ecery single loop R called the R-script > and performs the commands therein (or is supposed to perform it) on > the actual data file. > > After a loop finished, I tried appending the output to an output file. > > The problem is that R gives an error message saying that it cannot > open the input files. > > What can I do?Debug! R has many tools for convenient debugging. See the manuals, R News, or some good book on R. What can we do? We don't know anything about a) the files, b) the code and c) your intention! Uwe Ligges> Thanks, Matthew > > ______________________________________________ > 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
Sounds like you've got a file referencing problem. You may want to try and input the file into R using a simple read.table command or something similar without yet running your long script to see if your file can be called up. Tim ---- Original message ---->Date: Mon, 10 Jan 2005 13:55:28 +0100 (CET) >From: Cserh?ti M?ty?s <cs_matyi at freemail.hu> >Subject: [R] doing many commands within R >To: r-help at stat.math.ethz.ch > > > >Dear all, > >I'm new to this list, so let me greet everyone. > >My problem is that I have several thousand data files which Iwant to>perform a lot of R commands on, which are found in a seperate.R script.> >Now, what I did was within the R prompt, I used to read in alist of the>data files. > >e.g. > >namelist <- readLines("list_of_names",n=-1) >for (i in 1:100) { >k <- function(namelist[i]) >write(k,file="outputfile",append=TRUE) >} > >Next, I tried automating the R commands by making a loop.Within the>loop I called the R-script. Within ecery single loop R calledthe R-script>and performs the commands therein (or is supposed to performit) on>the actual data file. > >After a loop finished, I tried appending the output to anoutput file.> >The problem is that R gives an error message saying that itcannot>open the input files. > >What can I do? > >Thanks, Matthew > >______________________________________________ >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