If you just recently closed the unsaved (untitled) source tab in RStudio, there is a good chance that you can get it back. Try to restore unsaved RStudio script in 3 different ways.
1. If you are a Windows user, take a look at this folder that contains the folder that starts with “s-“. RStudio should be open.
There are usually files that end with “-contents”. Open some of them in a text editor and restore unsaved source code.
2. Take a look at the history_database file.
If you are a Windows user, the location of that file is here. It might be useful if previously described files are not available.
3. Take a look at the History tab.
Contents of the history tab are located in the Rhistory file. You can locate by using function getwd.
If you want to get the current RStudio script path, then here is how to do that.