Skip to content
Back to formatted view

Raw Message

Message-ID: <20050328025913.88421.qmail@web53506.mail.yahoo.com>
Date: 2005-03-28T02:59:13Z
From: Andrew Peterson
Subject: Can I use a variable to pass a file name to scan() ?

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.