[R] Can I use a variable to pass a file name to scan() ?
Andrew Peterson
andrew_g_peterson at yahoo.com
Mon Mar 28 04:59:13 CEST 2005
Hi, can anyone please tell me if it is possible to use
a variable to pass a file name to scan()?
I am trying to write a program that loops through a
series of text files. I use list.files() to create a
character vector of file names. Then I would like to
take one string at a time from the character vector
and use that string to specify the name of the text
file I want to open using scan().
I have used constructs such as
x <- list.files()
y <- scan(file = x[1])
but I always get the following error message:
Error in scan(file = x[1]) : "scan" expected a real,
got "<CLOSE>"
I've read all the documentation at least a couple of
times and have searched this list to no avail. Any
help would be greatly appreciated!
Thanks,
Andrew.
More information about the R-help
mailing list