3

When trying to save a script as an R file, I am not able to. The save as window opens, but the 'save as type' bar below the 'file name' bar is blocked/greyed-out. I am, however, able to save the script as an unreadable file. When I open it again to continue working on it, it cannot run. I then have to copy paste it to a new script to continue working on it and running the commands. I cannot seem to find many questions on the internet relating to this problem except this one: https://support.rstudio.com/hc/en-us/community/posts/219163988-Can-not-save-new-R-script-save-as-bar-grayed-out.

I have tried save() which does not work. I have also uninstalled R and installed the latest version of R, this does not help either. Would anyone know how to fix this problem so that I can save it as an R file?

EDITED:

I am using RStudio version 3.4.4. on the Windows 10 Home edition. Processor: Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz. RAM: 8.00 GB. System type: 64-bit Operating System, x64-based processor.

Many thanks

altfi_SU
  • 584
  • 1
  • 3
  • 15
  • Are you using RGui or RStudio or something else? What is your operating system. Please edit your question to put in these informations! (BTW: `save()` is for storing data objects.) – jogo Mar 19 '18 at 08:45
  • Thanks, @jogo, I'll include that information. I know `save()` is for storing data objects, but I looked into it further to see if it could save scripts. – altfi_SU Mar 19 '18 at 08:53
  • for RSudio: If your script is in the script-window (normally left upper panel) there is a row with small icons (above line 1 of your script): there you can use the discette-icon to save. If did your script in the console you can find it in the **History**-tab (right upper panel). From there you can copy it to the script window. Eventually you have to create a new script-window / -tab – jogo Mar 19 '18 at 09:09
  • I am working in the script window always. Clicking on the discette-icon, File -> Save As... and Ctrl+S all leads to the same problem of not being able to save type as R file. – altfi_SU Mar 19 '18 at 09:17
  • In this case it seems to be an administrative problem. (Eventually you don't have the rights to write a file in the desired directory.) Is there any error message? If yes, put it in your question, i.e. edit your question. – jogo Mar 19 '18 at 09:33
  • No, there is no error message and the problem persists in whichever directory I choose to save it in. I have even emailed RStudio in which I received a reply saying I should ask for assistance here rather. – altfi_SU Mar 19 '18 at 09:38

4 Answers4

4

friend!

I had the same problem as you. But what resolved was just put ".R" (example: save.R) in the end of the name, even with the grey bar, it generated the script automatically.

Hope it can help.

2

Windows 10 now prevents Rstudio to save a new document. Give Rstudio permission, restart it and than it worked for me.

GBerg
  • 21
  • 2
2

These other answers don't solve it for me. What I noticed is:

  1. Working off of a network drive is a nightmare for R Studio.

  2. Even if you do save it as an .R file, R Studio may not be able to open it.

What I did was:

  1. Paste my script into a notepad file; save it as .R

  2. Right click my .R file and Open With RStudio.

This minimizing RStudio doing the driving of opening files. And once the file is NAMED (it was named and saved as .R in notepad) RStudio seems to be able to save/overwrite changes to the file. It just cannot save the file the first time nor save TXT files it opens as .R files.

So yeah, for the initial script; template it in notepad and never change it's name.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Carlos Mercado
  • 165
  • 1
  • 5
1

By saving the R script with .R at the end automatically saves it as an R file!