Skip to content
Prev 86395 / 398506 Next

read.table

On Tue, 14 Feb 2006, Diethelm Wuertz wrote:

            
I think you might be stuck in a particular mindset about this.

Does the .csv file have to be called test.csv?

If not then if it is called data.csv say, you can have in your data 
directory a file test.R with the code:

read.table("data.csv", header = TRUE, sep = ";", check.names = FALSE)

Alternatively you can have the data in the file test.R, plus the code to 
read it in as desired. Creating a data structure and reading it back in 
with dput and dget is one way to do this.

See page 11 of the Writing R Extensions manual for the possible formats of 
files in the data directory:

"The data subdirectory is for additional data files the package makes 
available for loading using data(). Currently, data files can have one of 
three types as indicated by their extension: plain R code (.R or .r), 
tables (.tab, .txt, or .csv), or save() images (.RData or .rda). (All 
ports of R use the same binary (XDR) format and can read compressed 
images. Use images saved with save(, compress = TRUE) to save space.) Note 
that R code should be self-sufficient and not make use of extra 
functionality provided by the package, so that the data file can also be 
used without having to load the package."

David Scott



_________________________________________________________________
David Scott	Department of Statistics, Tamaki Campus
 		The University of Auckland, PB 92019
 		Auckland	NEW ZEALAND
Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
Email:	d.scott at auckland.ac.nz


Graduate Officer, Department of Statistics