[R] Scan() question

Jason Turner jasont at indigoindustrial.co.nz
Fri Oct 24 07:23:54 CEST 2003


Janice Warner wrote:

> I am just beginning to use R 1.7.1 on Windows XP and can not do a simple 
 > scan of a .txt file with integer data separated by tabs.
> 
> 
> First I figured out that I need to open a connection to the file 
 >(which isn't mentioned in scan()).

It isn't mentioned because it isn't needed.

I'd try

read.csv(filename,sep="\t") # for tab-separated files


 > But now when I scan,  I get "Read 0 items".  What can I do?

Shouldn't happen quite like that.

I have a file on my XP box, in my "My Documents" folder, called 
"foo.txt".  It's a two-column text file, tab-separated.  First column is 
  the numbers 1 to 12.  Second column is some random numbers.

 > scan("c:/documents and settings/jason turner/my documents/foo.csv")
Read 24 items
  [1]  1.00000000  0.05905332  2.00000000  0.21829890  3.00000000 
0.07104709
  [7]  4.00000000  0.67140721  5.00000000  0.44471572  6.00000000 
0.75093844
[13]  7.00000000  0.40647603  8.00000000  0.85937071  9.00000000  0.31583605
[19] 10.00000000  0.77993103 11.00000000  0.55067598 12.00000000  0.25861385

Notice the "/" rather than the "\" as the directory delimiter.

Cheers

Jason

-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
jasont at indigoindustrial.co.nz




More information about the R-help mailing list