The R program’s structure is similar to the programs written in other computer languages such as C or its successors C++ and Java. However, important differences between these languages and R are (i) R has no header files, (ii) most of the declarations are implicit, (iii) there are no pointers in R, and (iv) text and strings as vectors can be defined and manipulated directly.
R is a functional language. Most of the computation in R is handled using functions. The R language environment is designed to facilitate the development of new scientific computation tools.
Everything (such as functions and data structure) in R is an object. To see the names of all objects in R workspace, on R command prompt just type,
objects() is an alternative to ls() function. Similarly, typing the name of any object on R prompt displays (prints) the content of that object. As an example type q, mean, and lm etc. on R prompt.
It is possible to save individual object or collection of objects into a named image file. The named image file has an extension of .RData. Some possibilities to save an object from R workspace are:
To save the content of R workspace into a file .RData, type
To save objects in the file archive.RData, type
> save.image(file = “archive.RData”)
To save some required objects in data.RData, type
> save(x, y, file = “data.RData”)
These image files can be attached to make objects available in the next R session. For example.
> attached (“arvhive.RData”)
Note that when quitting, R offers the option of saving workspace image. By default, the workspace is saved in an image file (.RData) in the working directory. The image file can be used in the next R session. Saving the workspace image will save everything from the current workspace. Therefore, use rm() function to remove objects that are not further required in the next R session.