Skip to content
Prev 34589 / 398502 Next

How to read in data

Anne Piotet wrote:
- that's because it didnt find the file in that location.
- that's because it did find the file, but there was the text "No_D" 
in it. scan() will only read numbers unless you tell it otherwise.
again, its not looking in c:\, so it doesn't find it. Funny how 
scan("test.dat") brings up an error about "toto.txt" :)

  R has a working directory which is where scan() and read.file() will 
start looking for files without a full path - type getwd() to see where 
that is at any time.

  You didnt try the other option:

   test <- read.table("c:\\toto.txt", sep='\t')

- I give a full path to toto.txt and tell it the columns are separated 
with tabs ('\t'). You may need other options - popular ones are as.is=T 
which keeps character variables as text rather than converting to 
categorical data (factors), and head=T if the first line of the file is 
a header with column names.

  If this works, then do names(test) and summary(test) to see what 
you've got.
Depends - whats the size of the machine you are using (and dont say 
its a small box that fits under my monitor). How much RAM and disk space 
does it have?

Baz