Skip to content
Prev 374703 / 398513 Next

Can't open R files

Just for completeness: there are several ways to open files for editing in RStudio -

 * Configure your computer to be able to double-click on a file and open it
   in RStudio: this is OS dependent. Google for "change file associations"
   to get advice.

 * Drag and drop a file icon onto the RStudio icon.

 * When RStudio is running, 
   -  use the File -> open dialogue like Duncan said;
   -  if you have worked with the file recently, use the File -> Recent files ...
      dialogue;
   -  if the file is in your "working directory", it appears in the
      "file pane" of the RStudio window (bottom right). Click on the name.
      If it's not in the working directory, navigate the file pane by 
      clicking on the ".." to go to a parent folder, or on a folder name
      to descend into the folder;

  *  On the command line, execute file.edit("<filename>"). You can also put
     this command into a script that you source(). (But not in the .RProfile
     script.)

  *  Programmatically, you can readLines() a file, add and change contents
     and writeLines() the result.

Cheers,
B.