I Saving Data
by Doc P, 10 Jun 2020
One habit you should get into is to save a copy of everything you do for the class. If you are using the lab computers you will need to obtain a flash drive to save your files but I would recommend that you do so even if you are working with R on your own computer. Following are some suggestions for things you might want to save/keep as you are working on R problems.
Excel (or other spreadsheet) files
It is a good idea to keep a copy of every data set you go to the trouble of entering into Excel. We will be reusing many of the sets and that will keep you from having to repeat the tedious data entry process. I tend to keep both an Excel format version and a .csv version, but either would probably be sufficient.
R.data files
When you finish a problem or just quit R for any reason, it’s always a good idea to save the data you have been working on. If you do this you can reload the data set just as it was when you quit, which can save you a lot of time if you come back to the problem later on. To save data in .RData format, go under the dropdown menu for “Session”, click on “Save Workspace As…”, and specify the name and location where you want the file stored. I usually put things on the desktop and then move them where I want to store them.
A text file of the contents of your R console
This will be absolutely mandatory for any problem you need to turn in for me to evaluate. You can simply highlight part or all of the contents of your console, copy it and paste it into any text editor (Word Pad, Text Edit, etc.). Then save the file with a name that will tell you what it is (“Homework” probably isn’t a very good name. Something like “CH3Num5” is a lot more descriptive.
Use folders for things you save
Your flash drive will get messy quite quickly if you just dump everything into one big pile, so I highly recommend using folders to organize the information. You might have one folder for data, both .csv files and R.data files, so that you can set your working directory to look in that folder for data files. Others are up to you but I would suggest at least a file for text documents you have saved from the console. You might even want a folder for these crib sheets so that you have them handy and don’t need to download them from D2L every time you have a question.