31 August 2021
To make R easier to use, there are five things you should check.
1) Turn on file extensions on your computer. In R, you will need to know the full name of the file, including the extension (e.g., .txt., .csv, etc.). Many operating systems ship with the extensions invisible, so that you would see “myFile” instead of the full file name “myFile.txt”. To turn extensions on for a Mac, go to Finder … Preferences and check the box that says “Show all filename extensions”. On Windows, go to the Windows File Explorer, and in the controls at the top, look for one labeled “File name extensions”, and make sure that is checked.
2) RStudio will by default not only save all of your objects when you quit, it will automatically read them in when you start. This is often not a good idea, because you will not be starting with a clean slate when you start up. To fix this, Go to Preferences, select General, and under Workspace, uncheck the item that reads “Restore .RData into workspace at startup”. I would also recommend changing “Save workspace to .RData on exit” to Never. When you want to save your workspace, you will want to tell R to do this explicitly, using save.image() as we showed in class.
3) Although the R app does not automatically read in the .RData file like RStudio, it will always ask you if you want to save it whenever you are about to quit the app. Having R ask every time can be annoying. To turn this off in the R.app, go to R Preferences, select the General pane, and under “Save workspace on exit from R”, choose No.
4) You will find it useful to have R work in a directory of your choosing, and for it to automatically start with that directory when it launches. This will save you from having to call setwd() every time you start R. I prefer the Desktop as my working directory. You may have another preferred location, and that‘s fine; use whatever works best for you. In the preferences for R.app (only on the Mac) or RStudio, under General, you will see a place where you can change your initial working directory. Go ahead and set this to whatever you want.
5) Last, in the preferences windows for both apps, leave the option for saving your history checked (it should be on by default). Saving your history doesn‘t take much space and it‘s a good backstop in case you accidentally quit R before saving your commands.