0

I just started using R a couple of weeks ago, I'm a new student in a research group that uses the program.

My supervisor gave me a file with the ending .idx to open in R and work on. I was eventually able to open it yesterday, but it took me 45 minutes! I thought I'd figured out how to do it yesterday, but again today R is telling me the file doesn't exist.

Yesterday I used list.files and file.exists and the file magically seemed to exist.

Please can anybody tell me how to reopen saved files from R back on to the console?

ems501
  • 1
  • 1
  • 1
  • 1
    This is going to be very, very, very hard to debug remotely. Is there any chance you can get help from someone local, and preferably someone in your group (I have no idea what a `.idx` extension denotes ...) ? – Ben Bolker Sep 13 '17 at 18:36
  • What is the command line you are using to read the file? – Ryan Morton Sep 13 '17 at 18:37
  • PS. Have you set your working directory correctly? If you're not already doing so, using the RStudio interface might make your life (much) easier – Ben Bolker Sep 13 '17 at 18:37
  • 1
    You could specify your file with `file.choose` perhaps something like `read.table(file.choose())` – G5W Sep 13 '17 at 18:45
  • Thank you so much, the file.choose thing worked! It still says the file doesn't exist though, so I don't understand what's going on – ems501 Sep 13 '17 at 18:49

1 Answers1

1

R won't let me open saved file, says “no such file or directory”

It sounds like you just don't have the working directory set to the directory that contains the file in question. Try typing getwd() at the R command prompt and see what path it returns. Chances are, it's not the path were your file is. In that case, you can either move the file into R's current working directory, or you can type setwd("/path/to/the/file") at an R command prompt to set the path (obviously, /path/to/the/file should be replaced with the path to the directory containing your file).

Caleb
  • 124,013
  • 19
  • 183
  • 272
  • In addition to @Caleb's advice, I strongly suggest using RStudio, which should make loading/saving files easier for you. Another pesky beginner problem is that you need to make sure to use forward slashes (/) rather than back slashes (\). – Jordan Sep 14 '17 at 15:29