[R-SIG-Mac] Read csv

MacQueen, Don macqueen1 at llnl.gov
Thu Nov 16 23:29:25 CET 2017


In addition to which:

what does
   str(E)
show?

The file is small, so what do you get when you simply time
  E
at the R prompt?

header is TRUE by default in read.csv(), so it was unnecessary to supply header=T

read.csv2() has header=TRUE and sep=";" by default, so simply
    read.csv2('auto.csv')
should be sufficient if Tim's suggestion is the explanation.

read.csv() and friends are solid, reliable, and extremely well tested functions. If they don't succeed, you can assume that your data is different than expected. So inspect your data file to try and see what that might be.

Mac and Windows have different end-of-line conventions, but as far as I know read.csv and friends are smart enough to handle that.

Your locale setting might be relevant, but that's pretty much outside my experience.

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 11/13/17, 7:29 AM, "R-SIG-Mac on behalf of BATES Timothy" <r-sig-mac-bounces at r-project.org on behalf of tim.bates at ed.ac.uk> wrote:

    likely the separator character is not the default "," that csv expects.
    
    look in the csv file and see what the separator character is: perhaps it is a ";" 
    
    try:
    
    df <- read.csv("example.csv", header=TRUE, sep=";"); names(df)
    
    
    > On 13 Nov 2017, at 1:07 pm, 王宙翔 <wzx0908 at icloud.com> wrote:
    > 
    > Hi,Friends:
    > When I want to read datas from csv , I have the following problem.
    > For example:
    > auto.csv :
    > <PastedGraphic-1.png>
    > 
    > E <- read.csv("auto.csv", header=T)
    > But E$age is NULL
    > (on windows, E$age is not NULL).
    > Thank you ,everyone. I hope get this helps
    > Wang
    > _______________________________________________
    > R-SIG-Mac mailing list
    > R-SIG-Mac at r-project.org
    > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
    
    
    -- 
    The University of Edinburgh is a charitable body, registered in
    Scotland, with registration number SC005336.
    
    _______________________________________________
    R-SIG-Mac mailing list
    R-SIG-Mac at r-project.org
    https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list