[R] packaged datasets in .csv format (David Firth)

Andrew C. Ward s195404 at student.uq.edu.au
Fri Jul 11 00:39:29 CEST 2003


This information and advice is indeed very useful.

Some would wonder, however, whether a file delimited with semi-
colons can still be called a CSV file. Excel Help has "CSV (Comma
delimited) format") ;-)

Regards,

Andrew C. Ward

CAPE Centre
Department of Chemical Engineering
The University of Queensland
Brisbane Qld 4072 Australia
andreww at cheque.uq.edu.au


Quoting David Firth <david.firth at nuffield.oxford.ac.uk>:

> Many thanks to those who replied to my question.
> 
> Dirk's suggestion, to use a .R file in the "data" directory of
> the  
> package, specifying how the .csv should be read, works fine as
> an  
> answer to the question about making comma-separated files
> available.
> 
> Uwe's answer to my other question (; vs ,), ie compatibility
> with  
> existing R packages, is well taken!
> 
> Cheers,
> David
> 
> On Thursday, Jul 10, 2003, at 12:25 Europe/London, Uwe Ligges
> wrote:
> 
> > Andreas Christmann wrote:
> >>>
> ----------------------------------------------------------------
-----
> 
> >>> -
> >>>
> >>> Message: 1
> >>> Date: Wed, 9 Jul 2003 10:53:27 +0100
> >>> From: David Firth <david.firth at nuffield.oxford.ac.uk>
> >>> Subject: [R] packaged datasets in .csv format
> >>> To: r-help at stat.math.ethz.ch
> >>> Message-ID:
> >>>    
> <307D34CE-B1F3-11D7-A8D2-0050E4C03977 at nuffield.oxford.ac.uk>
> >>> Content-Type: text/plain; charset=US-ASCII; format=flowed
> >>>
> >>> A couple of questions in connection with using .csv format
> to  
> >>> include data in a package:
> >>>
> >>> First, the background.  The data() function loads data from
> .csv  
> >>> ("comma-separated values") files using
> >>>
> >>>    read.table(..., header = TRUE, sep = ";")
> >>>
> >>> But ?read.table says
> >>>
> >>>       ## To write a CSV file for input to Excel one might
> use
> >>>       write.table(x, file = "foo.csv", sep = ",", col.names
> = NA)
> >>>       ## and to read this file back into R one needs
> >>>       read.table("file.csv", header = TRUE, sep = ",",
> row.names=1)
> >>>
> >>> As a result, .csv files created by write.table() as above
> are not  
> >>> read in by data() in the way that might be expected [that
> is,  
> >>> expected by someone who had not read help(data)!]
> >>>
> >>> Two questions, then:
> >>> -- is there some compelling reason for  the use of `sep =
> ";"' in  
> >>> place of `sep = ",", row.names=1'?
> >
> > Do you really want an answer?
> > Today, one reason is compatibility to all the other packages
> on CRAN.
> >
> >
> >> I prefer ";" instead of "," , because in text variables
> there are  
> >> often ",".
> >
> > That's why text variables can be quoted.
> >
> >
> >>> -- if I want to maintain a dataset in .csv format, for use
> both in R  
> >>> and in other systems such as Excel, SPSS, etc, what is the
> best way  
> >>> to go about it?
> >
> > When regularly using that many systems on the same data sets,
> it might  
> > be worth using a database system, e.g. MySQL.
> >
> > BTW: R *and* Excel *and* (for sure, but I haven't tested)
> also SPSS  
> > can read a couple of different ASCII formatted files, so
> there are  
> > quite a lot possible formats.
> >
> > Uwe Ligges
> >
> >
> >> Depends. Perhaps it is best to check it out for the software
> packages
> >> and the versions of the software packages you are using.
> > >
> >> Andreas Christmann
> >>>
> >>> Any advice would be much appreciated.
> >>>
> >>> Cheers,
> >>> David
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list