Skip to content

Automating R for multiple data files

2 messages · Brian Ripley, Adam Tee

#
On Thu, 1 May 2003, Adam Tee wrote:

            
files <- list.files(pattern="^haydn1stmvt.jtf")

and then a for loop over `files' would appear to do what I think (but am 
unsure) you want.
#
Hi,

I'm new to R and have looked at the mail archives and not
seen a solution to my problem.

I have a set of data files with filenames in the following form
haydn1stmvt.jtf.sim0.142292.et.dist, where the latter half
changes, after the jtf.

What I am trying to do is process the set of these files using
R's batch mode. using the following :

library(mva)

mdsdata <- read.table(file)
cm <- cmdscale(mdsdata)
x <- cm[,1]
y <- -cm[,2]

postscript("file.eps", height=5, width=5)
plot(x,y,type="n", main="classical MDS")
text(x,y,names(mdsdata))
dev.off()

I want the variable file to contain the relevant file name with
having to input it manually for each file. Is there an easy solution to 
this ??


Thanks

Adam Tee
PhD Student
University of Leeds