Skip to content
Prev 66634 / 398525 Next

Can I use a variable to pass a file name to scan() ?

Andrew Peterson wrote:

            
Yes.
Right, the file named in x[1] is a text file that starts with "<CLOSE>" 
which is not a number (and scan expects a number, by default), hence 
scan complains.

Use
    y <- scan(file = x[1], what="character")
and you will see that it works.

Uwe Ligges