RStudio Can't Save Script - New to R

Could somebody please explain how to save and reopen a .R file, with the script? My project looks like it's saving, but when I reopen, the script is gone.

Here's what I'm doing:

  • In RStudio, I go to "New," choose "New Script"
  • I type out my script, something really simple right now (names and dates).
  • I save the script, using the "Save" feature at the top of the editor. I name the script when prompted.
  • I close R, then reopen my project from where it's saved in a folder on my desktop.
  • Anything I created (e.g. the dataframe) is there, but not the script.

What am I doing wrong? I'm on a Mac, FWIW.

(I should add, I'm obviously typing in the console. I'm not sure where the script will reappear?)

Never mind, I figured it out.

I should not have been typing in the console.

Thanks anyway!

If you're typing in the console that code is not being saved in the script. You need to type in the file itself. To ensure you have the script pane open you can go to View > Panes > Show All Panes. The place to edit your script file will have a ribbon atop it with things like the save icon, run lines, etc.

You can type in this window and then send that code to the console to be executed. Once you've completed a line or lines of code, select what you want to be executed and press Ctrl+Enter. If nothing is selected it will execute whatever line the cursor is on.

As I was typing this I saw you figured out the issue but I figured I'd still submit in case someone else came along and had the same question later.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.