Saving Session in RStudio

New to RStudio, working on my first project. I am trying to save my session but when I click the Save icon, it does not give me a file type to associate with the file. Likewise when I click File > Save or FIle > Save As, I get no file type.

I assume I have done something wrong or am missing a step. If I just need to input the filetype, is it .RMD or what?

Generally people save scripts (.R files) or R markdown files (.Rmd). By default, when you open RStudio, there are 4 panes. RStudio User Guide - Pane Layout

If you've been only entering code directly into the console (which is my guess), there's easy way to save the "session". I recommend writing code into a script (.R) file and saving that so you can reproduce it later.

Some resources of workflows:

I have been using the source pane. I only really use the console for things i don't want to keep like repeatedly doing View, summary, str commands (I have the newbie "I don't trust myself" thing going right now so I check that too often, but don't want that all in the scripts that i want to actually hang on to.

When I click on the save icon at the top of the Source pane, it does not give me any options in the Save as Type field. I tried just entering filename.r in the file name field but it just throws a File not found error like it is looking for a file rather than just saving what i have done.

Is it possible you're trying to save a file to a place you don't have write access? By default, the file type is ".R"

The file type is set when you create the file. For instance, if you use File > New File > R Script or click the New File button on the toolbar and choose R Script, you get an unnamed file that RStudio knows is an R script.

You can change the file type by saving it with a new extension. Suppose I start with File > New File > RScript and then try to save it as myfile.Rmd. RStudio will warn me that the file is an R script and ask me to confirm the format change. If I do confirm, the file will become an Rmd file. (I think the warning only comes the first time you change a file's type.) If I save it as myfile.cpp, RStudio will change the file type to C++ source code, and so on.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.