Warning message: In file(file, "rt")

Siya picture Siya · Jan 17, 2013 · Viewed 8.9k times · Source

I am trying to import CSV files to graph for a project. I'm using R 2.15.2 on a Mac OS X.

  • The first way tried

    The script I'm trying to run to import the CSV file is this:

    group4 <- read.csv("XXXX.csv", header=T)
    

    But I keep getting this error message:

    Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
      object 'XXXXXX.csv' not found 
    
  • The second way tried

    I tried moving my working directory but got another error saying I can't move my working directory. So I went into Preferences tab and changed the working directory to the file that has my CSV files. But I still get the same error(as the first way).

  • The third way tried

    Then I tried this script:

    group4 <- read.table(file.choose(), sep="\t", header=T)
    

    And I get this error:

    Warning message: 
    In read.table(file.choose(), sep = "\t", header = T) :
      incomplete final line found by readTableHeader on '/Users/xxxxxx/Documents/Programming/R/xxxxxx/xxxxxx.csv' 
    

I've searched on the R site and all over the Internet, and nothing has got me to the point where I can import this simple CSV file into the R console.

Answer

Paul Hiemstra picture Paul Hiemstra · Jan 17, 2013
  1. The file is not in your working directory, change it, or use an absolute path.
  2. Than you are pointing to a non-existing directory, or you do not have write privileges there.
  3. The last line of your file is malformed.