I do not know how to fix that error from within RStudio but the first thing I would do is copy all of the text in the file, paste it into a plain text editor and save that file (with a new name) using the .R extension. If you are on Windows, you can use NotePad. If you are sure you will not lose any other work, you can then close and restart RStudio. The content of the file you were trying to save will be preserved in the file made from NotePad.