This part of the tutorial series applies if you're running R straight from the command line. RStudio should have equivalent GUI options that are not difficult to find. Even if you plan on exclusively using RStudio, this page should still be worth the read.
When you're just about done working for the day, you can close R with the
q() command. However, what about all that work you've done and the variables you've created. What if you want to save them for your next session? We may do so with by saving to R's dataset.
Before we save our workspace, let's check to see which objects are currently in your environment. Use the
ls() command. This will list out all objects created.
> ls()  "sayHello" "x" "y"
Your output will be slightly different, depending on how much tinkering you've done during this tutorial.
By default, when you select the "y" option when you quit (
q()), the dataset will be saved to .RData file, located from where you ran the R session from. This file loads automatically when you start R, as long as you start R within the same directory as that file.
We may also save and load to a file manually.
To save an R environment, use the
save.image() command with the name of the file as the argument.
This will save firstSession.RData onto your current working directory.
To load your current dataset, use the
load() command with your filename.
This will load all the variables from your previous session.
In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.$ Check price
Easy to understand and fun to read, Introducing Python is ideal for beginning programmers as well as those new to the language. Author Bill Lubanovic takes you from the basics to more involved and varied topics, mixing tutorials with cookbook-style code recipes to explain concepts in Python 3. End-of-chapter exercises help you practice what you learned.$ Check price